Migrate Azure VM From Unmanaged Disks To Managed Disks with Azure PowerShell

4 Min. Read

In this article, we will show you how to convert and migrate an Azure virtual machine from UnManaged Disks to Managed Disks and remove the extra layer of administrative overhead.


In June 2017, Microsoft announced a new type of storage account known as “Managed Disks“. Managed Disks is an exciting new feature from Azure, designed to help with the availability, manageability, scalability, and performance of virtual machine disks storage within Azure.

The difference between Managed and Unmanaged Disks is going to determine the amount of administrative overhead and also some of the technical limitations that govern how many disks you have, how they’re laid out, how they’re backed up, and how well they perform. The technical limitations are covered in detail here.

With UnManaged Disks it’s up to you the administrator to do things like replication, optimize disks for performance, and make sure that the disks are actually kept secure. For Managed Disks, Azure does all of this for you.

With Unmanaged Disks, you create a storage account. You put those disks in a storage account. You then govern access to those disks using Role-Based Access Control tagging or locking at the storage account level. So you may wind up with if you have a lot of virtual machines, and you need to separate everything, you need many unmanaged storage accounts and this could be a challenge for management.

As for the pricing is per storage, it uses storage account pricing for Unmanaged disks. For Managed it’s simply based on the size of the disk. How you place the storage account, what regions, and how you replicate it, with Unmanaged you do all the work, with managed Azure does that for you. With managed disks, the charge is by capacity not by consumption (i.e. For 1B HDD/SSD, you will pay for 1000GB even if you only used 1GB), with Unmanaged disks you pay on consumption (i.e. you have 1TB HDD/SSD disk, and you used 1GB, you will pay for 1GB).

And then finally for accessibility, for UnManaged Disks you can use the storage account data to get access to the actual VHD files. With Managed Disks, you have to export those VHD files and at that point, Azure generates a one-time-key and you’re able to export the disk. But, again the difference here is with an UnManaged Disk you have to first create the storage account, then create the disks, and then you manage the disks by managing the storage account. So there’s this additional layer that you’ve got it responsible for. Now that you might have benefited from that, you may want to have that additional level of control.

You may want to give different users the ability to go in and access the raw VHDs through the storage account. If you do then, UnManaged is probably the way to go. But, if you simply want the VM and just you don’t want to worry about the VHDs just put them on Azure and make sure they’re good, then a Managed Disk is the right choice for you.

The question is, what if you have an existing VM with an UnManaged Disk, can I convert it to Managed Disk? The short answer is, YES!

Migrate Azure VM to Managed Disks

Let’s go ahead and convert a VM from an unmanaged disk to a managed disk.

If you have a VM that you deployed before you used managed disks, or you decided you want to simplify and go from an unmanaged disk configuration to a managed disk configuration. Either way, it’s a fairly simple process. The only disruptive point is you do need to power off the VM in order to do it. So you’ve to take that into consideration in terms of things like downtime, availability of applications. But if this is a non-critical VM then it’s no big deal, you can go ahead and do it.

In this example, I’ve got a VM called adPDC, adPDC uses unmanaged disks. As you can see in the screenshot below, it’s got an operating system disk.

Migrate Azure VM From Unmanaged Disks To Managed Disks with Azure PowerShell 1

If I click on the OS disk, you can see it’s actually using a storage account. So this is an unmanaged disk.

Migrate Azure VM From Unmanaged Disks To Managed Disks with Azure PowerShell 2

Now let’s convert it using PowerShell.

Assuming you have installed the Az PowerShell module and you have already logged on to Azure using Connect-AzAccount cmdlet.

You can go a step further and just dig a little bit into the disk configuration, and look at the operating system disk using the StorageProfile property. As you can see this is not a managed disk. You can see the fact that there’s no value, it’s essentially false.

Migrate Azure VM From Unmanaged Disks To Managed Disks with Azure PowerShell 3

Now let’s go ahead and do the conversion. First, you need to Stop (Deallocate) the VM using the Stop-AzVM followed by the VM name and resource group name. This might take a couple of minutes.

Stop-AzVM -Name <VMName> -ResourceGroupName <ResourceGroupName>

Migrate Azure VM From Unmanaged Disks To Managed Disks with Azure PowerShell 4

So the VM is shut down, now we can actually go ahead and do the conversion. And to do this, we need to run a PowerShell command that’s explicitly for this task. The command is ConvertTo-AzVMManagedDisk followed by the VM name and resource group name.

ConvertTo-AzVMManagedDisk -Name <VMNam> -ResourceGroupName <ResourceGroupName>

What this command do behind the scene, it actually performs the migration from an unmanaged disk to an Azure-managed disk. And that process takes a little bit of time. In this example, the conversion took a little over two minutes.

Migrate Azure VM From Unmanaged Disks To Managed Disks with Azure PowerShell

Let’s go ahead and start the VM using the Start-AzVM cmdlet, and take a look at the configuration. We’ll query the StorageProfile property for our disk configuration. As you can see now that it is a managed disk.

Migrate Azure VM From Unmanaged Disks To Managed Disks with Azure PowerShell 5

Hope this helps!

Learn more on how to rename an Azure Virtual Machine with PowerShell.


Related Posts


Microsoft Announced The Preview Release Of Windows Server 2019

Add Windows Server 2019 Image to AzureStack #AzureStackDevKit #WindowsServer2019


2 thoughts on “Migrate Azure VM From Unmanaged Disks To Managed Disks with Azure PowerShell”

Leave a comment...

  1. It should be noted that managed disks charge by capacity not consumption. A 1B HDD bills for 1000GB if only 1GB used. Unmanaged disks bill on consumption. Use 1GB on a 1TB HDD disk; pay for 1GB.

    Good article with done real world considerations.

Let me know what you think, or ask a question...

The content of this website is copyrighted from being plagiarized!

You can copy from the 'Code Blocks' in 'Black' by selecting the Code.

Please send your feedback to the author using this form for any 'Code' you like.

Thank you for visiting!