Passer au contenu principal


Today, we announce Azure CLI support for Azure Managed Disks!

Microsoft announced the general availability of Azure Managed Disks – it simplifies the management and scaling of Virtual Machines.  The Managed Disks experience in Azure CLI is idomatic to the CLI experience in other cross-platform tools, and we know you will love it!

You can use the Azure CLI to administer Managed Disks: check out the install guide for information on how to install or update the Azure CLI.

Create Standalone Managed Disks

You can easily create standalone Managed Disks in a variety of ways.

Create an empty Managed Disk.

  az disk create -n myDisk -g myResourceGroup --size-gb 20

Create a Managed Disk from Blob Storage.

  az disk create -g myResourceGroup -n myDisk

Create a Managed Disk from an existing image.

  az disk create -n myDisk -g myResourceGroup
​    --source <>/Microsoft.Compute/disks/mdvm1_OsDisk_1_

It's as easy as that, and each of these disks can be subsequently attached to a Virtual Machine (see below).

Create Virtual Machines with Managed Disks

You can create a Virtual Machine with an implicit Managed Disk for a specific disk image.  Creation is simplified with implicit creation of managed disks without specifying all the disk details. You do not have to worry about creating and managing Storage Accounts.

A Managed Disk is created implicitly when creating VM from an OS image in Azure.

  az vm create -n myVm -g myResourceGroup --generate-ssh-keys --image UbuntuLTS

This Managed Disk is created by default, and you can easily verify its ID by using the –query feature of Azure CLI.

  az vm list -o tsv
      --query "[].{ name:name, }"

As mentioned previously, you can easily attach a previously provisioned Managed Disk.

  az vm disk attach --vm-name myVm -g myResourceGroup
    --disk <>/Microsoft.Compute/disks/testmd

Create a new VM Scale Set with new resources (Virtual Machines and Managed Disks) from an image.

  az vmss create -n myVmScaleSet -g myResourceGroup --admin-username 
    --admin-password  --instance-count 4 --image Win2012R2Datacenter

Update and Take Snapshots with Managed Disks

Resizing a managed disk from the Azure CLI is easy and straightforward.

  az disk update -n myDisk -g myResourceGroup -z 25

You can also update the Storage Account type of the Managed Disks.

  az disk update -n myDisk -g myResourceGroup --sku Standard_LRS

Create an image from Blob Storage.

  az image create -g myResourceGroup -n myImage --os-type Linux 
    --source < uri to an os disk blob...>

Create a snapshot of a Managed Disk that is currently attached to a Virtual Machine.

  az snapshot create -g myResourceGroup -n mySnapshot
    --source <>/Microsoft.Compute/disks/mdvm1_OsDisk_1_

Try It

You can run the examples above as they appear (with the proper values, of course). Give it a try and let us know what do you think (in the comments below).  Azure CLI has more exciting services on the way, and we are excited to hear your thoughts on how the idiomatic experience integrates with the shell tools you know and love.

  • Explore


    Let us know what you think of Azure and what you would like to see in the future.


    Provide feedback

  • Build your cloud computing and Azure skills with free courses by Microsoft Learn.


    Explore Azure learning

Join the conversation