| title | Azure Resource Manager: Create an Azure SQL Managed Instance |
|---|---|
| description | Learn how to create an Azure SQL Managed Instance by using an Azure Resource Manager template. |
| author | urosmil |
| ms.author | urmilano |
| ms.reviewer | mathoma |
| ms.date | 06/22/2020 |
| ms.service | azure-sql-managed-instance |
| ms.subservice | deployment-configuration |
| ms.topic | quickstart |
| ms.custom | subject-armqs, mode-arm, devx-track-arm-template, ignite-2023 |
This quickstart focuses on the process of deploying an Azure Resource Manager template (ARM template) 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.
[!INCLUDE About Azure Resource Manager]
If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.
- 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 template used in this quickstart is from Azure Quickstart Templates.
Key template parameters
| Parameter name | Default / Example | Allowed values / Constraints | Description |
|---|---|---|---|
| managedInstanceName | sqlmi | 1–63 characters | Name of the SQL managed instance |
| location | resourceGroup().location | Azure regions that support SQL managed instance | Region for all resources |
| administratorLogin | sqladmin | Cannot be reserved words | SQL administrator login |
| administratorLoginPassword | — | Minimum length and complexity enforced | SQL administrator password |
| vCores | 8 | Valid vCore values per SKU | Compute size of the instance |
| storageSizeInGB | 256 | Min/Max per service tier | Storage allocated to the instance |
| subnetAddressPrefix | 10.0.0.0/24 | Dedicated, delegated subnet required | Subnet for the managed instance |
:::code language="json" source="~/../quickstart-templates/quickstarts/microsoft.sql/sqlmi-new-vnet/azuredeploy.json":::
These resources are defined in the template:
- Microsoft.Network/networkSecurityGroups
- Microsoft.Network/routeTables
- Microsoft.Network/virtualNetworks
- Microsoft.Sql/managedinstances
More template samples can be found in Azure Quickstart Templates.
Select Try it from the following PowerShell code block to open Azure Cloud Shell.
Deployment checklist
- Verify prerequisites:
- Active Azure subscription
- Required permissions (SQL Managed Instance Contributor or Microsoft.Sql/managedInstances/write)
- Run the deployment command (PowerShell or Azure CLI) using the snippets below.
- Verify success:
- In the Azure portal, the deployment shows Succeeded
- The SQL managed instance appears in the target resource group with state Creating or Ready
Important
Deploying a SQL managed instance is a long-running operation. Deployment of the first instance in the subnet typically takes much longer than deploying into a subnet with existing managed instances. For average provisioning times, see SQL Managed Instance management operations.
$projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names"
$location = Read-Host -Prompt "Enter the location (i.e. centralus)"
$templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.sql/sqlmi-new-vnet/azuredeploy.json"
$resourceGroupName = "${projectName}rg"
New-AzResourceGroup -Name $resourceGroupName -Location $location
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri
Read-Host -Prompt "Press [ENTER] to continue ..."
read -p "Enter a project name that is used for generating resource names:" projectName &&
read -p "Enter the location (i.e. centralus):" location &&
templateUri="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.sql/sqlmi-new-vnet/azuredeploy.json" &&
resourceGroupName="${projectName}rg" &&
az group create --name $resourceGroupName --location "$location" &&
az deployment group create --resource-group $resourceGroupName --template-uri $templateUri &&
echo "Press [ENTER] to continue ..." &&
read
Visit the Azure portal and verify the managed instance is in your selected resource group. Because creating a managed instance can take some time, you might need to check the Deployments link on your resource group's Overview page.
- For a quickstart that shows how to connect to SQL Managed Instance from an Azure virtual machine, see Configure an Azure virtual machine connection.
- For a quickstart that shows how to connect to SQL Managed Instance from an on-premises client computer by using a point-to-site connection, see Configure a point-to-site connection.
Keep the managed instance if you want to go to the Next steps, but delete the managed instance and related resources after completing any additional tutorials. After deleting a managed instance, see Delete a subnet after deleting a managed instance.
To delete the resource group:
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
Remove-AzResourceGroup -Name $resourceGroupName
echo "Enter the Resource Group name:" &&
read resourceGroupName &&
az group delete --name $resourceGroupName
[!div class="nextstepaction"] Configure an Azure VM to connect to Azure SQL Managed Instance