Skip to content

Latest commit

 

History

History
104 lines (70 loc) · 4.16 KB

File metadata and controls

104 lines (70 loc) · 4.16 KB
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

Quickstart: Create an Azure SQL Managed Instance using 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.

Prerequisites

  • 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.

Review the Bicep file

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:

Deploy the Bicep file

  1. Save the Bicep file as main.bicep to your local computer.

  2. 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.

Review deployed resources

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

Clean up resources

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

Next steps

[!div class="nextstepaction"] Configure an Azure VM to connect to Azure SQL Managed Instance