title | description | keywords | services | documentationcenter | author | manager | editor | ms.assetid | ms.service | ms.custom | ms.workload | ms.tgt_pltfrm | ms.devlang | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Quick start: Your first Azure SQL Database | Microsoft Docs |
Learn how to create a SQL Database logical server, server-level firewall rule, and databases with the Azure portal. You also learn to use SQL Server Management Studio with Azure SQL Database. |
sql database tutorial, create a sql database |
sql-database |
CarlRabeler |
jhubbard |
aeb8c4c3-6ae2-45f7-b2c3-fa13e3752eed |
sql-database |
single databases |
data-management |
na |
na |
hero-article |
02/04/2017 |
carlrab |
In this quick start tutorial, you learn how to:
- Create a new logical server
- View the logical server properties
- Create a server-level firewall rule
- Connect to the server with SSMS
- Create a database with sample data
- View the database properties
- Query the database in the Azure portal
- Connect and query the database with SSMS
- Create a blank database with SSMS
- Troubleshoot connectivity
- Delete a database
In this quick start tutorial, you create a sample database and a blank database running in an Azure resource group and attached to a logical server. You also create two server-level firewall rules configured to enable the server-level principal to log in to the server from two specified IP addresses. Finally, you learn how to query a database in the Azure portal and to connect and query using SQL Server Management Studio.
Time estimate: This tutorial takes approximately 30 minutes (assuming you already meet the prerequisites).
Tip
You can perform these same tasks with either C# or PowerShell.
-
You need an Azure account. You can open a free Azure account or Activate Visual Studio subscriber benefits.
-
You must be able to connect to the Azure portal with an account that is a member of either the subscription owner or contributor role. For more information on role-based access control (RBAC), see Getting started with access management in the Azure portal.
Note
This quick start tutorial helps you to learn the content of these learn topics: SQL Database server overview, SQL database overview, and Overview of Azure SQL Database firewall rules.
with your Aure account, follow these steps to connect to the Azure portal.
-
Open your browser of choice and connect to the Azure portal.
-
Sign in to the Azure portal.
-
On the Sign in page, provide the credentials for your subscription.
Follow the steps in this procedure to create a new logical server with the Azure portal in the region of your choice.
-
Click New, type sql server, and then click ENTER.
-
Click SQL server (logical server).
-
Click Create to open the new SQL Server (logical server) blade.
-
In the Server name text box, provide a valid name for the new logical server. A green check mark indicates that you have provided a valid name.
[!IMPORTANT] The fully qualified name for your new server is in the form of: <your_server_name>.database.windows.net.
-
In the Server admin login text box, provide a user name for the SQL authentication login for this server. This login is known as the server principal login. A green check mark indicates that you have provided a valid name.
-
In the Password and Confirm password text boxes, provide a password for the server principal login account. A green check mark indicates that you have provided a valid password.
-
Select a subscription in which you have permission to create objects.
-
In the Resource group text box, select Create new and then, in the resource group text box, provide a valid name for the new resource group (you can also use an existing resource group if you have already created one for yourself). A green check mark indicates that you have provided a valid name.
-
In the Location text box, select a data center appropriate to your location - such as "Australia East".
[!TIP] The checkbox for Allow azure services to access server cannot be changed on this blade. You can change this setting on the server firewall blade. For more information, see Get started with security.
-
Click Create.
Follow the steps in this procedure to view the server properties with the Azure portal. You need the fully qualified server name to connect to this server in a subsequent procedure.
-
In the Azure portal, click More services.
-
In the Filter text box, type SQL and then click the star for SQL servers to specify SQL servers as a favorite within Azure.
-
In the default blade, click SQL servers to open the list of SQL servers in your Azure subscription.
-
Click your new SQL server to view its properties in the Azure portal. Subsequent tutorials help you understand the options available to you on this blade.
-
Under Settings, click Properties to view various properties of the logical SQL server.
-
Copy the fully qualified server name to your clipboard for use a bit later in this tutorial.
Follow the steps in this procedure to create a new server-level firewall rule with the Azure portal to enable you to connect to your server with SQL Server Management Studio in the next procedure.
-
On the SQL server blade, under Settings, click Firewall to open the Firewall blade for the SQL server.
-
Click Add client IP on the toolbar.
[!NOTE] You can open the SQL Database firewall on the server to a single IP address or an entire range of addresses. Opening the firewall enables SQL administrators and users to login to any database on the server to which they have valid credentials.
-
Click Save on the toolbar to save this server-level firewall rule and then click OK.
Follow the steps in this procedure to connect to the SQL logical server with SQL Server Management Studio.
-
If you have not already done so, download and install the latest version of SSMS at Download SQL Server Management Studio. To stay up-to-date, the latest version of SSMS prompts you when there is a new version available to download.
-
After installing, type Microsoft SQL Server Management Studio in the Windows search box and click Enter to open SSMS:
-
In the Connect to Server dialog box, enter the necessary information to connect to your SQL server with SQL Server Authentication.
-
Click Connect.
-
In Object Explorer, expand Databases, expand System Databases, expand master to view objects in the master database.
-
Right-click master and then click New Query.
-
In the query window, type the following query:
select * from sys.objects
-
On toolbar, click Execute to return a list of all system objects in the master database.
[!NOTE] To explore SQL security, see Get Started with SQL security
Follow the steps in this procedure to create a database with sample data with the Azure portal. You create this database attached to the logical server that you previously created. If the Basic service tier is not available in the region in which you created your server, delete your server and recreate it in another region. For deletion steps, see the last procedure in this tutorial.
-
In Azure portal, click SQL databases in the default blade.
-
On the SQL databases blade, click Add.
-
On the SQL Database blade, review the information completed for you.
-
Provide a valid database name.
-
Under Select source, click Sample and then underSelect sample, click AdventureWorksLT [V12].
-
Under Server, provide the server admin login user name and password.
[!NOTE] When adding a database to a server, it can be added as a single database (this is the default) or added to an elastic pool. For more information on elastic pools, see Elastic pools.
-
Under Pricing tier, change the pricing tier to Basic (you can increase the pricing tier later if desired, but for learning purposes, we recommend you use the lowest cost tier).
-
Click Create.
Follow the steps in this procedure to query the database with the Azure portal.
-
On the SQL databases blade, click your new database to view its properties in the Azure portal. Subsequent tutorials help you understand the options available to you on this blade.
-
Click Properties to view additional information about your database.
-
Click Show database connection strings.
-
Click Overview and then click your server name in the Essentials pane.
-
In the Essentials pane for your server, see your newly added database.
Follow the steps in this procedure to query the database with the query editor in the Azure portal. The query shows the objects in the database.
-
On the SQL databases blade, click Tools on the toolbar.
-
On the Tools blade, click Query editor (preview).
-
Click the checkbox to acknowledge that the query editor is a preview feature and then click OK.
-
On the Query editor blade, click Login.
-
Review the Authorization type and Login, then provide the password for this login.
-
Click OK to attempt to login.
-
When you receive a login error stating that your client does not permission to log in due to the absence of firewall rule for your client's IP address, copy your client's IP address in the error window and, on the SQL server blade for this database, create a server-level firewall rule.
-
Repeat the previous 6 steps to log in to your database.
-
After you are authenticated, in the query window, type the following query:
select * from sys.objects
-
Click Run.
-
Review the query results in theResults pane.
Follow the steps in this procedure to connect to the database with SQL Server Management Studio and then query the sample data to view the objects in the database.
-
Switch to SQL Server Management Studio and, in Object Explorer, click Databases and then click Refresh on the toolbar to view the sample database.
-
In Object Explorer, expand your new database to view its objects.
-
Right-click your sample database and then click New Query.
-
In the query window, type the following query:
select * from sys.objects
-
On toolbar, click Execute to return a list of all system objects in the sample database.
Follow the steps in this procedure to create a new database on the logical server with SQL Server Management Studio.
-
In Object Explorer, right-click Databases and then click New database.
[!NOTE] You can also have SSMS create a create database script for you to create a new database with Transact-SQL.
-
In the New Database dialog box, provide a database name in the Database name text box.
-
In the New Database dialog box, click Options and then change the Edition to Basic.
[!TIP] Review the other options in this dialog box that you can modify for an Azure SQL Database. For more information on these options, see Create Database.
-
Click OK to create the blank database.
-
When complete, refresh the Database node in Object Explorer to view the newly created blank database.
Important
If you have connectivity issues, see Connectivity issues.
Follow the steps in this procedure to delete a single database with the Azure portal.
-
On the blade in the Azure portal for your SQL database, click Delete.
-
Click Yes to confirm that you want to delete this database permanently.
Tip
During the retention period for your database, you can restore it from the service-initiated automatic backups. For Basic edition databases, you can restore them within seven days. However, do not delete a server. If you do so, you cannot recover the server or any of its deleted databases. For more information about database backups, see Learn about SQL Database backups and for information about restoring a database from backups, see Database recovery. For a how-to article on restoring a deleted database, see Restore a deleted Azure SQL database - Azure portal.
Now that you've completed this tutorial, there are number of additional tutorials that you may wish to explore that build what you have learned in this tutorial.
- For a getting started with SQL Server authentication tutorial, see SQL authentication and authorization
- For a getting started with Azure Active Directory authentication tutorial, see AAD authentication and authorization
- If you want to query the sample database in the Azure portal, see Public preview: Interactive query experience for SQL databases
- If you know Excel, learn how to Connect to a SQL database in Azure with Excel.
- If you're ready to start coding, choose your programming language at Connection libraries for SQL Database and SQL Server.
- If you want to move your on-premises SQL Server databases to Azure, see Migrating a database to SQL Database.
- If you want to load some data into a new table from a CSV file with the BCP command-line tool, see Loading data into SQL Database from a CSV file with BCP.
- If you want to start creating tables and other objects, see the "To create a table" topic in Creating a table.
- For a technical overview see What is SQL Database?
- For pricing information, see Azure SQL Database pricing.