|
| 1 | +--- |
| 2 | +title: "Bicep: Create a single database in Azure SQL Database" |
| 3 | +description: Create a single database in Azure SQL Database using Bicep. |
| 4 | +services: sql-database |
| 5 | +ms.service: sql-database |
| 6 | +ms.subservice: deployment-configuration |
| 7 | +ms.custom: subject-armqs sqldbrb=1, devx-track-azurepowershell, mode-arm |
| 8 | +ms.topic: quickstart |
| 9 | +author: schaffererin |
| 10 | +ms.author: v-eschaffer |
| 11 | +ms.date: 05/16/2022 |
| 12 | +--- |
| 13 | + |
| 14 | +# Quickstart: Create a single database in Azure SQL Database using Bicep |
| 15 | + |
| 16 | +Creating a [single database](single-database-overview.md) 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. |
| 17 | + |
| 18 | +[Bicep](/azure/azure-resource-manager/bicep/overview?tabs=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. |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/). |
| 23 | + |
| 24 | +## Review the Bicep file |
| 25 | + |
| 26 | +A single database has a defined set of compute, memory, IO, and storage resources using one of two [purchasing models](purchasing-models.md). When you create a single database, you also define a [server](logical-servers.md) to manage it and place it within [Azure resource group](/azure/active-directory-b2c/overview) in a specified region. |
| 27 | + |
| 28 | +The Bicep file used in this quickstart is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/sql-database/). |
| 29 | + |
| 30 | +:::code language="bicep" source="~/../quickstart-templates/quickstarts/microsoft.sql/sql-database/main.bicep"::: |
| 31 | + |
| 32 | +The following resources are defined in the Bicep file: |
| 33 | + |
| 34 | +- [**Microsoft.Sql/servers**](/azure/templates/microsoft.sql/servers) |
| 35 | +- [**Microsoft.Sql/servers/databases**](/azure/templates/microsoft.sql/servers/databases) |
| 36 | + |
| 37 | +## Deploy the Bicep file |
| 38 | + |
| 39 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 40 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 41 | + |
| 42 | + # [CLI](#tab/CLI) |
| 43 | + |
| 44 | + ```azurecli |
| 45 | + az group create --name exampleRG --location eastus |
| 46 | + az deployment group create --resource-group exampleRG --template-file main.bicep --parameters administratorLogin=<admin-login> |
| 47 | + ``` |
| 48 | +
|
| 49 | + # [PowerShell](#tab/PowerShell) |
| 50 | +
|
| 51 | + ```azurepowershell |
| 52 | + New-AzResourceGroup -Name exampleRG -Location eastus |
| 53 | + New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -administratorLogin "<admin-login>" |
| 54 | + ``` |
| 55 | +
|
| 56 | + --- |
| 57 | +
|
| 58 | +> [!NOTE] |
| 59 | +> Replace **\<admin-login\>** with the administrator username of the SQL logical server. You'll be prompted to enter **administratorLoginPassword**. |
| 60 | +
|
| 61 | + When the deployment finishes, you should see a message indicating the deployment succeeded. |
| 62 | +
|
| 63 | +## Review deployed resources |
| 64 | +
|
| 65 | +Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group. |
| 66 | +
|
| 67 | +# [CLI](#tab/CLI) |
| 68 | +
|
| 69 | +```azurecli-interactive |
| 70 | +az resource list --resource-group exampleRG |
| 71 | +``` |
| 72 | + |
| 73 | +# [PowerShell](#tab/PowerShell) |
| 74 | + |
| 75 | +```azurepowershell-interactive |
| 76 | +Get-AzResource -ResourceGroupName exampleRG |
| 77 | +``` |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## Clean up resources |
| 82 | + |
| 83 | +When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources. |
| 84 | + |
| 85 | +# [CLI](#tab/CLI) |
| 86 | + |
| 87 | +```azurecli-interactive |
| 88 | +az group delete --name exampleRG |
| 89 | +``` |
| 90 | + |
| 91 | +# [PowerShell](#tab/PowerShell) |
| 92 | + |
| 93 | +```azurepowershell-interactive |
| 94 | +Remove-AzResourceGroup -Name exampleRG |
| 95 | +``` |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## Next steps |
| 100 | + |
| 101 | +- 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](firewall-create-server-level-portal-quickstart.md). |
| 102 | +- After you create a server-level firewall rule, [connect and query](connect-query-content-reference-guide.md) your database using several different tools and languages. |
| 103 | + - [Connect and query using SQL Server Management Studio](connect-query-ssms.md) |
| 104 | + - [Connect and query using Azure Data Studio](/sql/azure-data-studio/quickstart-sql-database?toc=%2fazure%2fsql-database%2ftoc.json) |
| 105 | +- To create a single database using the Azure CLI, see [Azure CLI samples](az-cli-script-samples-content-guide.md). |
| 106 | +- To create a single database using Azure PowerShell, see [Azure PowerShell samples](powershell-script-content-guide.md). |
| 107 | +- To learn how to create Bicep files, see [Create Bicep files with Visual Studio Code](/azure/azure-resource-manager/bicep/quickstart-create-bicep-use-visual-studio-code). |
0 commit comments