This post will show you how to convert a virtual machine, whether within an availability group or a single instance, from unmanaged disks (Storage Account) to disks managed using Azure PowerShell.

Requirements: This tutorial assumes that you already have a Microsoft Azure account set up.

Important: Before starting the conversion process, you should keep in mind the following.

  • The conversion requires a restart of the VM
  • The conversion is not reversible.
  • The virtual machine will receive a new IP address after the conversion if it uses dynamic IP.
  • The VHDs and the storage account used by the VM before conversion are not deleted.

Azure PowerShell Workaround

If you want to know how to install the PowerShell Azure module on your machine, check out this link.

The simplest way to get started is to sign in interactively at the command line.

This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account.
If you have more than one subscription associated with your mail account, you can choose the default subscription. To perform this task, we will use the following commands:

Convert a single VM from Unmanaged disk to Managed disk

Set the variables
Here, we define the characteristics of our environment

Check what type of disk the VM uses

To verify that the machine does not use managed disks, use Get-AzVM with the following syntax:

If the value of the “ManagedDisk” property is empty, the machine uses unmanaged disks.


Deallocate the Virtual Machine

To deallocate the VM, use the Stop-AzVM cmdlet with the following syntax:

Convert the VM to managed disks

To convert all the disks of the VM (os disk and data disk) to managed disks, use the ConvertTo-AzVMManagedDisk cmdlet with the following syntax:


When verifying again with the Get-AzVM cmdlet, we see that the “ManagedDisk” property is not empty.

Azure Managed Disk

Convert VM’s in an availability set to managed disks

Set the variables
Here, we define the characteristics of our environment

Convert the availability set to a managed availability set

Before converting virtual machines, you must first convert the availability set to a managed availability set. To do this, use the Update-AzAvailabilitySet cmdlet with the following syntax:


Deallocate and convert the VMs in the availability set

With the following script, we go through all the virtual machines within the availability group. First, we deallocate them with the Stop-AZM cmdlet and then convert them with the ConvertTo-AzVMManagedDisk cmdlet.

Azure Managed Disk

If you want to know more about Azure Managed Disks, check out this link: