Skip to content

Latest commit

 

History

History
369 lines (232 loc) · 20.5 KB

sql-database-get-started.md

File metadata and controls

369 lines (232 loc) · 20.5 KB
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

Quick start tutorial: Your first Azure SQL database

In this quick start tutorial, you learn how to:

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.

Prerequisites

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.

Sign in to the Azure portal with your Azure account

with your Aure account, follow these steps to connect to the Azure portal.

  1. Open your browser of choice and connect to the Azure portal.

  2. Sign in to the Azure portal.

  3. On the Sign in page, provide the credentials for your subscription.

    Sign in

Create a new logical SQL server

Follow the steps in this procedure to create a new logical server with the Azure portal in the region of your choice.

  1. Click New, type sql server, and then click ENTER.

    logical sql server

  2. Click SQL server (logical server).

    create-logical sql server

  3. Click Create to open the new SQL Server (logical server) blade.

    new-logical sql server

  4. 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.

    new server name

    [!IMPORTANT] The fully qualified name for your new server is in the form of: <your_server_name>.database.windows.net.

  5. 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.

    SQL admin login

  6. 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.

    SQL admin password

  7. Select a subscription in which you have permission to create objects.

    subscription

  8. 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.

    new resource group

  9. In the Location text box, select a data center appropriate to your location - such as "Australia East".

    server location

    [!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.

  10. Click Create.

    create button

View the logical server properties

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.

  1. In the Azure portal, click More services.

    more services

  2. In the Filter text box, type SQL and then click the star for SQL servers to specify SQL servers as a favorite within Azure.

    set favorite

  3. In the default blade, click SQL servers to open the list of SQL servers in your Azure subscription.

    new sql server

  4. 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.

    sql server blade

  5. Under Settings, click Properties to view various properties of the logical SQL server.

    sql server properties

  6. Copy the fully qualified server name to your clipboard for use a bit later in this tutorial.

    sql server full name

Create a server-level firewall rule

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.

  1. On the SQL server blade, under Settings, click Firewall to open the Firewall blade for the SQL server.

    sql server firewall

  2. Click Add client IP on the toolbar.

    add client IP

    [!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.

  3. Click Save on the toolbar to save this server-level firewall rule and then click OK.

    add client IP

Connect to the server with SSMS

Follow the steps in this procedure to connect to the SQL logical server with SQL Server Management Studio.

  1. 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.

  2. After installing, type Microsoft SQL Server Management Studio in the Windows search box and click Enter to open SSMS:

    SQL Server Management Studio

  3. In the Connect to Server dialog box, enter the necessary information to connect to your SQL server with SQL Server Authentication.

    connect to server

  4. Click Connect.

    connected to server

  5. In Object Explorer, expand Databases, expand System Databases, expand master to view objects in the master database.

    master database

  6. Right-click master and then click New Query.

    query master database

  7. In the query window, type the following query:

    select * from sys.objects

  8. On toolbar, click Execute to return a list of all system objects in the master database.

    query master database system objects

    [!NOTE] To explore SQL security, see Get Started with SQL security

Create a database with sample data

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.

  1. In Azure portal, click SQL databases in the default blade.

    sql databases

  2. On the SQL databases blade, click Add.

    add sql database

  3. On the SQL Database blade, review the information completed for you.

    sql database blade

  4. Provide a valid database name.

    sql database name

  5. Under Select source, click Sample and then underSelect sample, click AdventureWorksLT [V12].

    adventure works lt

  6. Under Server, provide the server admin login user name and password.

    server credentials

    [!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.

  7. 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).

    pricing tier

  8. Click Create.

    create button

View the database properties

Follow the steps in this procedure to query the database with the Azure portal.

  1. 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.

    new sample db blade

  2. Click Properties to view additional information about your database.

    new sample db properties

  3. Click Show database connection strings.

    new sample db connection strings

  4. Click Overview and then click your server name in the Essentials pane.

    new sample db essentials pane

  5. In the Essentials pane for your server, see your newly added database.

    new sample db in server essentials pane

Query the database in the Azure portal

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.

  1. On the SQL databases blade, click Tools on the toolbar.

    tools

  2. On the Tools blade, click Query editor (preview).

    query editor

  3. Click the checkbox to acknowledge that the query editor is a preview feature and then click OK.

  4. On the Query editor blade, click Login.

    query editor blade

  5. Review the Authorization type and Login, then provide the password for this login.

    query editor login

  6. Click OK to attempt to login.

  7. 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.

    query editor error

  8. Repeat the previous 6 steps to log in to your database.

  9. After you are authenticated, in the query window, type the following query:

    select * from sys.objects

    query editor query

  10. Click Run.

  11. Review the query results in theResults pane.

    query editor results

Connect and query the database with SSMS

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.

  1. Switch to SQL Server Management Studio and, in Object Explorer, click Databases and then click Refresh on the toolbar to view the sample database.

    new sample db with ssms

  2. In Object Explorer, expand your new database to view its objects.

    new sample db objects with ssms

  3. Right-click your sample database and then click New Query.

    new sample db query with ssms

  4. In the query window, type the following query:

    select * from sys.objects

  5. On toolbar, click Execute to return a list of all system objects in the sample database.

    new sample db query system objects with ssms

Create a blank database with SSMS

Follow the steps in this procedure to create a new database on the logical server with SQL Server Management Studio.

  1. In Object Explorer, right-click Databases and then click New database.

    new blank database with ssms

    [!NOTE] You can also have SSMS create a create database script for you to create a new database with Transact-SQL.

  2. In the New Database dialog box, provide a database name in the Database name text box.

    new blank database name with ssms

  3. In the New Database dialog box, click Options and then change the Edition to Basic.

    new blank database options with ssms

    [!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.

  4. Click OK to create the blank database.

  5. When complete, refresh the Database node in Object Explorer to view the newly created blank database.

    new blank database in object explorer

Troubleshoot connectivity

Important

If you have connectivity issues, see Connectivity issues.

Delete a single database

Follow the steps in this procedure to delete a single database with the Azure portal.

  1. On the blade in the Azure portal for your SQL database, click Delete.

    delete-database

  2. Click Yes to confirm that you want to delete this database permanently.

    delete-database-yes

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.

Next steps

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.

Additional resources