title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | ms.custom |
---|---|---|---|---|---|---|---|---|---|
Bicep: Create a single database in Azure SQL Database |
Create a single database in Azure SQL Database using Bicep. |
dimitri-furman |
dfurman |
mathoma |
05/16/2022 |
sql-database |
deployment-configuration |
quickstart |
subject-armqs sqldbrb=1, mode-arm, devx-track-bicep |
[!INCLUDEappliesto-sqldb]
Creating a single database is the quickest and simplest option for creating a database in Azure SQL Database. This quickstart shows you how to create a single database using Bicep.
Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.
If you don't have an Azure subscription, create a free account.
A single database has a defined set of compute, memory, IO, and storage resources using one of two purchasing models. When you create a single database, you also define a server to manage it and place it within Azure resource group in a specified region.
The Bicep file used in this quickstart is from Azure Quickstart Templates.
:::code language="bicep" source="~/../quickstart-templates/quickstarts/microsoft.sql/sql-database/main.bicep":::
The following resources are defined in the Bicep file:
-
Save the Bicep file as main.bicep to your local computer.
-
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
az group create --name exampleRG --location eastus az deployment group create --resource-group exampleRG --template-file main.bicep --parameters administratorLogin=<admin-login>
New-AzResourceGroup -Name exampleRG -Location eastus New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -administratorLogin "<admin-login>"
Note
Replace <admin-login> with the administrator username of the SQL logical server. You'll be prompted to enter administratorLoginPassword.
When the deployment finishes, you should see a message indicating the deployment succeeded.
Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.
az resource list --resource-group exampleRG
Get-AzResource -ResourceGroupName exampleRG
When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources.
az group delete --name exampleRG
Remove-AzResourceGroup -Name exampleRG
- Create a server-level firewall rule to connect to the single database from on-premises or remote tools. For more information, see Create a server-level firewall rule.
- After you create a server-level firewall rule, connect and query your database using several different tools and languages.
- To create a single database using the Azure CLI, see Azure CLI samples.
- To create a single database using Azure PowerShell, see Azure PowerShell samples.
- To learn how to create Bicep files, see Create Bicep files with Visual Studio Code.