Azure Command Line Interface (CLI) enables you to quickly and easily work with your Azure SQL Managed Instances (MI). In this post, you will demonstrate basic CLI commands that can be used with Azure SQL MI.

Azure CLI commands may be executed a number of ways 

Once you sign-in and open terminal, make sure that you set the subscription that you will use using something like the following command:

az account set --subscription <your subscription id here>

Working with Managed Instances

The first thing we do in the administration is to list the entities we manage:

az sql mi list

This will list all the MI in the set subscription in a large JSON document.

You may filter the search by specifying azure resource group where you want to search for the instances using the -g <resource group name> option. If you want more advanced filtering, you can specify JMESPath query string  in --query parameter.

The command az sql mi create will create a new MI:

az sql mi create -n <mi name> -u <mi admin> -p <mi admin password>
           -g <mi resource group> -l <azure location>
           --vnet-name <name of vnet> --subnet <name of subnet>

When the command execution is complete the properties of the newly created MI is displayed as JSON text. You may also specify the following optional properties for the MI:

  • -c the number of cores that will be assigned to the instance.
  • --storage storage size expressed in GB
  • --tier– GeneralPurpose or BusinessCritical
  • --license-type–  that can be BasePrice or LicenseIncluded
  • --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 mi_name -u mi_admin -p mi_password
            -g mi_group
            -l "East US"
            --vnet-name mi_vnet --subnet mi_subnet
            -c 8 --storage 256 --tier BusinessCritical --license-type LicenseIncluded --family Gen4

Details of an MI can be displayed with the following command:

az sql mi show -n mi_name -g mi_group

You may alter the properties of an MI with the following command:

az sql mi update -g mi_group -n mi_name --storage 64

It is typical to increase the storage size limit or number of cores assigned to the managed instance over time.

Delete a MI with the following command:

az sql mi delete -g mi_group -n mi_name


One you learn Azure CLI it might become a handy way to control your resources and change the properties of your managed instances. You can find the complete list of AZ commands that can be used to control managed instance on the  Azure documentation page.

Categories: Article