Quickstart: Create an Azure SQL Database single database

In this quickstart, you use the Azure portal, a PowerShell script, or an Azure CLI script to create a single database in Azure SQL Database. You then query the database using Query editor in the Azure portal.

A single database is the quickest and simplest option for Azure SQL Database. You manage a single database within a server, which is inside an Azure resource group in a specified Azure region. In this quickstart, you create a new resource group and server for the new database.

You can create a single database in the provisioned or serverless compute tier. A provisioned database is pre-allocated a fixed amount of compute resources, including CPU and memory, and uses one of two purchasing models. This quickstart creates a provisioned database using the vCore-based purchasing model, but you can also choose a DTU-based model.

The serverless compute tier is only available in the vCore-based purchasing model, and has an autoscaled range of compute resources, including CPU and memory. To create a single database in the serverless compute tier, see Create a serverless database.

Prerequisite

Create a single database

In this step, you create a logical SQL server and a single database that uses AdventureWorksLT sample data. You can create the database by using Azure portal menus and screens, or by using an Azure CLI or PowerShell script in the Azure Cloud Shell.

All the methods include setting up a server-level firewall rule to allow the public IP address of the computer you're using to access the server. For more information about creating server-level firewall rules, see Create a server-level firewall. You can also set database-level firewall rules. See Create a database-level firewall rule.

To create a resource group, server, and single database in the Azure portal:

  1. Sign in to the portal.

  2. From the Search bar, search for and select Azure SQL.

  3. On the Azure SQL page, select Add.

    Add to Azure SQL

  4. On the Select SQL deployment option page, select the SQL databases tile, with Single database under Resource type. You can view more information about the different databases by selecting Show details.

  5. Select Create.

    Create single database

  6. On the Basics tab of the Create SQL database form, under Project details, select the correct Azure Subscription if it isn't already selected.

  7. Under Resource group, select Create new, enter myResourceGroup, and select OK.

  8. Under Database details, for Database name enter mySampleDatabase.

  9. For Server, select Create new, and fill out the New server form as follows:

    • Server name: Enter mysqlserver, and some characters for uniqueness.
    • Server admin login: Enter azureuser.
    • Password: Enter a password that meets requirements, and enter it again in the Confirm password field.
    • Location: Drop down and choose a location, such as (US) East US.

    Select OK.

    New server

    Record the server admin login and password so you can log in to the server and its databases. If you forget your login or password, you can get the login name or reset the password on the SQL server page after database creation. To open the SQL server page, select the server name on the database Overview page.

  10. Under Compute + storage, if you want to reconfigure the defaults, select Configure database.

    On the Configure page, you can optionally:

    • Change the Compute tier from Provisioned to Serverless.
    • Review and change the settings for vCores and Data max size.
    • Select Change configuration to change the hardware generation.

    After making any changes, select Apply.

  11. Select Next: Networking at the bottom of the page.

    New SQL database - Basic tab

  12. On the Networking tab, under Connectivity method, select Public endpoint.

  13. Under Firewall rules, set Add current client IP address to Yes.

  14. Select Next: Additional settings at the bottom of the page.

    Networking tab

    For more information about firewall settings, see Allow Azure services and resources to access this server and Add a private endpoint.

  15. On the Additional settings tab, in the Data source section, for Use existing data, select Sample.

  16. Select Review + create at the bottom of the page.

    Additional settings tab

  17. After reviewing settings, select Create.

Query the database

Once your database is created, you can use the built-in Query editor in the Azure portal to connect to the database and query the data.

  1. In the portal, search for and select SQL databases, and then select your database from the list.

  2. On the SQL Database page for your database, select Query editor (preview) in the left menu.

  3. Enter your server admin login information, and select OK.

    Sign in to Query editor

  4. Enter the following query in the Query editor pane.

    SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName
    FROM SalesLT.ProductCategory pc
    JOIN SalesLT.Product p
    ON pc.productcategoryid = p.productcategoryid;
    
  5. Select Run, and then review the query results in the Results pane.

    Query editor results

  6. Close the Query editor page, and select OK when prompted to discard your unsaved edits.

Clean up resources

Keep the resource group, server, and single database to go on to the next steps, and learn how to connect and query your database with different methods.

When you're finished using these resources, you can delete the resource group you created, which will also delete the server and single database within it.

To delete myResourceGroup and all its resources using the Azure portal:

  1. In the portal, search for and select Resource groups, and then select myResourceGroup from the list.
  2. On the resource group page, select Delete resource group.
  3. Under Type the resource group name, enter myResourceGroup, and then select Delete.

Next steps

Connect and query your database using different tools and languages:

Want to optimize and save on your cloud spending?