SQL Database tutorial: Get started with Azure SQL Database servers, databases, and firewall rules using the Azure portal and SQL Server Management Studio
In this getting-started tutorial, you learn how to use the Azure portal to:
- Create a new Azure resource group
- Create an Azure SQL logical server
- View Azure SQL logical server properties
- Create a server-level firewall rule
- Create the Adventure Works LT sample database as a single database
- View Adventure Works LT sample database properties in Azure
In this tutorial, you also use the most recent version of SQL Server Management Studio to:
- Connect to the logical server and its master database
- Query the master database
- Connect to the sample database
- Query the sample database
When you finish this tutorial, you will have a sample database and a blank database running in an Azure resource group and attached to a logical server. You will also have a server-level firewall rule configured to enable the server-level principal to log in to the server from a specified IP address (or IP address range).
Time estimate: This tutorial will take you approximately 30 minutes (assuming you already meet the prerequisites).
You must be able to connect to the Azure portal using 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.
Sign in to the Azure portal using your Azure account
Using your existing subscription, 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.
Create a new logical SQL server in the Azure portal
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.
The fully qualified name for your new server will be
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".
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.
View the logical SQL Server properties in the Azure portal
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.
Create a server-level firewall rule in the Azure portal
On the SQL server blade, under Settings, click Firewall to open the Firewall blade for the SQL server.
Review the client IP address displayed and validate that this is your IP address on the Internet using a browser of your choice (ask "what is my IP address). Occasionally they do not match for a various reasons.
Assuming that the IP addresses match, click Add client IP on the toolbar.
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.
Connect to SQL server using SQL Server Management Studio (SSMS)
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 using SQL Server Authentication.
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.
To explore SQL security, see Get Started with SQL security
Create new database in the Azure portal using Adventure Works LT sample
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.
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).
View database properties in 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.
Connect and query sample database using SQL Server Management Studio
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.
Create a new blank database using SQL Server Management Studio
In Object Explorer, right-click Databases and then click New database.
You can also have SSMS create a create database script for you to create a new database using 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.
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.
You can save some money while you are learning by deleting databases that you are not using. 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.
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.
- If you want to start exploring Azure SQL Database security, see Getting started with security.
- 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 by using the BCP command-line tool, see Loading data into SQL Database from a CSV file using BCP.
- If you want to start creating tables and other objects, see the "To create a table" topic in Creating a table.