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 This Article
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.
If I click on the OS disk, you can see it’s actually using a storage account. So this is an unmanaged disk.
Now let’s convert it using PowerShell.
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.
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>
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.
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.
Hope this helps!
Learn more on how to rename an Azure Virtual Machine with PowerShell.