Create Azure SQL Managed Instance using Azure CLI
Azure command line interface (CLI) is a set of commands that you can use to create and manage Azure resources. In this post your will see how can you create Managed Instance using Azure CLI.
The Azure CLI is Microsoft's cross-platform command-line experience for managing Azure resources. You can use it in your browser with Azure Cloud Shell, or install it on macOS, Linux, or Windows and run it from the command line.
Azure CLI enables you to create new managed instances using az sql mi create command.
The prerequisite for this sample is to prepare Azure resource group , Virtual Network and subnet where the Managed Instance will be created using the instructions described here. The easiest way to setup environment is to use ARM template deployment as described in this post.
Make sure that you set the subscription that you will use using something like the following command:
az account set --subscription b9c7a824-4bde-06c0-9778-e7c2a70573e1
Replace the value
b9c7a824-4bde-06c0-9778-e7c2a70573e1 with your subscription id.
Creating Managed Instance
The command az sql mi create will create a new Managed Instance:
az sql mi create -n jovanpop-temp-mi -u myMiAdmin -p Stron9Pwd1234 -g mi_group -l "West Central US" --vnet-name mi_vnet --subnet mi_subnet
In this command you need to specify the name of new managed instance (-n), admin username(-u) and password(-p), resource group where it should be placed (-g), location(data center) where the instance will be placed (-l), and VNet/subnet where the instance will be configured.
If the command succeeds, you will see the properties of the created Managed Instance in the output as JSON text. Note that newly created Managed Instance will not be shown in the Azure deployments.
You can also specify the following properties of new Managed Instance in this command:
-cnumber of cores that will be assigned to the instance.
--storagestorage size expressed in GB
--license-type– that can be BasePrice or LicenseIncluded
--tier– GeneralPurpose or BusinessCritical
--family– hardware family that can be Gen4 or Gen
A command that specifies all these properties is shown in the following example:
az sql mi create -n jovanpop-temp-mi -u myMiAdmin -p StrongPwd1234 -g mi_group -l "West Central US" --vnet-name mi_vnet --subnet mi_subnet -c 8 --storage 256 --tier BusinessCritical -license-type LicenseIncluded --family Gen4
When this command finishes, yo can get the details of the created intance using the following command:
az sql mi show -n jovanpop-temp-mi -g mi_group