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.
- An active Azure subscription. If you don't have one, create a free account.
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:
Sign in to the portal.
From the Search bar, search for and select Azure SQL.
On the Azure SQL page, select Add.
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.
On the Basics tab of the Create SQL database form, under Project details, select the correct Azure Subscription if it isn't already selected.
Under Resource group, select Create new, enter myResourceGroup, and select OK.
Under Database details, for Database name enter mySampleDatabase.
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.
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.
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.
Select Next: Networking at the bottom of the page.
On the Networking tab, under Connectivity method, select Public endpoint.
Under Firewall rules, set Add current client IP address to Yes.
Select Next: Additional settings at the bottom of the page.
For more information about firewall settings, see Allow Azure services and resources to access this server and Add a private endpoint.
On the Additional settings tab, in the Data source section, for Use existing data, select Sample.
Select Review + create at the bottom of the page.
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.
In the portal, search for and select SQL databases, and then select your database from the list.
On the SQL Database page for your database, select Query editor (preview) in the left menu.
Enter your server admin login information, and select OK.
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;
Select Run, and then review the query results in the Results pane.
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:
- In the portal, search for and select Resource groups, and then select myResourceGroup from the list.
- On the resource group page, select Delete resource group.
- Under Type the resource group name, enter myResourceGroup, and then select Delete.
Connect and query your database using different tools and languages:
Want to optimize and save on your cloud spending?