Migrate Azure VM From Unmanaged Disks To Managed Disks

5 Min. Read

Migrating an Azure VM from unmanaged disks to managed disks involves converting the storage configuration of the VM from using Azure Storage accounts to using Azure Managed Disks. This process has several benefits, including improved performance, better reliability, and easier management.

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

Introduction

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 disk 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 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 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 do you place the storage account, what regions, and how do 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 Azure 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, and 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 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 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 the 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 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 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, is 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 5

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

Migrate to Managed Disks using the Azure Portal

Microsoft has simplified the migration process from unmanaged to managed disks, so you can do the complete migration in the Azure portal and the platform will handle everything for your automatically.

You will see an informational message for the VM which is not using Managed Disks as shown in the figure below. You can click on the message and perform the migration on the fly.

Migrate to Managed Disks using the Azure Portal
Migrate to Managed Disks using the Azure Portal

The source unmanaged disks are not deleted after the migration. Managed Disks are created by making a copy of the source disks. You can revert back to unmanaged disks by creating a new VM with the source disks. The configuration of the VMs is not changed after the migration.

Please note that the virtual machine will be stopped and restarted after the migration is complete.

Managed Disks simplify disk management for VMs by managing the Storage accounts behind the scenes. Managed Disks also provide granular access control with RBAC and better reliability for VMs in an Availability Set.

Summary

To migrate a VM from unmanaged disks to managed disks, you can use the Azure Portal, Azure PowerShell as described in this article, or Azure CLI. The process involves stopping the VM, creating a snapshot of the VM’s disks, creating new managed disks from the snapshot, and then attaching the new disks to the VM. Once the new disks are attached, you can start the VM and verify that everything is working correctly.

It’s important to note that the migration process can take some time, depending on the size and complexity of the VM. Additionally, there may be some differences in the way that managed disks handle certain storage operations, so it’s important to test the VM thoroughly after the migration to ensure that everything is functioning as expected.

Overall, migrating an Azure VM from unmanaged disks to managed disks can provide significant benefits in terms of performance, reliability, and manageability, and is a worthwhile process to consider for any Azure VM that is currently using unmanaged disks.

__
Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Previous

Microsoft Announced The Preview Release Of Windows Server 2019

Add Windows Server 2019 Image to Azure Stack Hub #AzureStackDevKit #WindowsServer

Next

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

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 us know what you think, or ask a question...