| title | Bicep: Create an Azure SQL Managed Instance using Bicep |
|---|---|
| description | Learn how to create an Azure SQL Managed Instance using Bicep. |
| author | MladjoA |
| ms.author | mlandzic |
| ms.reviewer | mathoma |
| ms.date | 05/16/2022 |
| ms.service | azure-sql-managed-instance |
| ms.subservice | deployment-configuration |
| ms.topic | quickstart |
| ms.custom | subject-armqs, mode-arm, devx-track-bicep |
This quickstart focuses on the process of deploying a Bicep file to create an Azure SQL Managed Instance and vNet. Azure SQL Managed Instance is an intelligent, fully managed, scalable cloud database, with almost 100% feature parity with the SQL Server database engine.
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.
- An Azure subscription. If you don't have an Azure subscription, create a free account
- In the general case, your user needs to have the role SQL Managed Instance Contributor assigned at subscription scope.
- If provisioning in a subnet that is already delegated to Azure SQL Managed Instance, your user only needs the Microsoft.Sql/managedInstances/write permission assigned at subscription scope.
The Bicep file used in this quickstart is from Azure Quickstart Templates.
:::code language="bicep" source="~/../quickstart-templates/quickstarts/microsoft.sql/sqlmi-new-vnet/main.bicep":::
These resources are defined in the Bicep file:
- Microsoft.Network/networkSecurityGroups
- Microsoft.Network/routeTables
- Microsoft.Network/virtualNetworks
- Microsoft.Sql/managedinstances
-
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 managedInstanceName=<instance-name> administratorLogin=<admin-login>New-AzResourceGroup -Name exampleRG -Location eastus New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -managedInstanceName "<instance-name>" -administratorLogin "<admin-login>"
Note
Replace <instance-name> with the name of the managed instance. Replace <admin-login> with the administrator username. 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
[!div class="nextstepaction"] Configure an Azure VM to connect to Azure SQL Managed Instance