Converting Azure VM Unmanaged Disks To Managed Disks

What are managed disks

 
Well, as the name suggests – managed disks are nothing but the disks which someone is managing for you; i.e., Azure is managing your VM’s disks for you. Hold on! The next obvious question pops up - what is the advantage of letting someone manage my VM’s disks; and the answer is quite simple; i.e., peace of mind and the ease of management. Isn’t it? True to some extent, however, let’s try to understand few details of it.
 
Each HDD disk has max IO of 500 IOPS limitation and since in Azure these disks are stored in the storage account which has limitation of 20000 IOPS, this means that each storage account can host up to maximum 40 disks before it reaches the limits. In certain situations, e.g. scaling up you might want to make sure that you don’t end up reaching these limitations and get in a tricky situation, to address this usually create multiple storage accounts and distribute our disks in these storage accounts, however, management of these storage accounts could become cumbersome at times.
 
Let's try and think about another scenario when you have your VHD image and you are creating VMs using it. Now, to do that, you would have needed to upload the same VHD multiple times in multiple storage accounts. All of these issues are addressed by managed disks offerings since we do not really need to worry about IOPS and placements of these disks to multiple storage account. Also, you can simply upload custom VHD image centrally to one location and use it to create multiple VMs.

Prerequisites for conversion
 
Only those unmanaged disk VMs are supported whose disks are stored inside the storage account on which storage encryption services have never been enabled. In order to carry out the conversion of the disks stored in storage accounts with enabled storage encryption then the VHD files need to be copied using AzCopy to another storage account on which SSE is never enabled.
 
Demo (VM without availability set)
 
In this scenario, we have previously created ARM VM which has an OS disk and three data disks attached (1GB each), out of which two are standard HDD disks and one is premium (SSD) disk stored in premium storage account. Also, note that this article demonstrates the conversion of the VM which is not part of any availability set. 
 
 

You might have noticed that all these disks are not encrypted. Now in order to convert the standard disks to managed disks – the below PowerShell command needs to be executed
  1. ConvertTo-AzureRmVMManagedDisk  
If you are unable to see the command mentioned above, then you will probably need to update the Azure PowerShell modules and this can be done using simply command 
  1. Install-Module AzureRM   
Note that, in order to perform this disk conversion, the virtual machine needs to be turned off. If the command is run directly on a running VM, it throws an exception clearly mentioning that the operation cannot be performed since the VM is not deallocated.
 
Let’s go ahead and turn our VM off using the portal.

Once the PS modules are updated, we will go ahead launch Azure PowerShell and run below commands
 
 
Once the command runs successfully, it gives summary of the execution.  
 
 
We should be able to see the managed disks created in the same resource group where VM is provisioned. Also, on successful completion the VM is automatically started.
 
The disk volumes created from attached data disks and all the data can also be seen on the VM and this can be validated by RDP’ing to the VM.

What about the old disks?
 
Well, if the conversion is successful and all the data is still intact then we can simply go ahead and delete the original disks associated with the VM. In our scenario, since our storage account which were dedicatedly created for provisioning VM disks and after the conversion of disks, those becomes of no use for us and hence can be deleted and some cost can be saved there.
 
Editing or Adding new disks to VM 
 
At any point of time, we can go ahead and resize the disks using Azure portal. 
 
 

For adding new disks, we simply need to select the VM and select Disks option from the settings blade and click on Add data disk option.
As seen in the image below, it shows options to create the disk.
 
Select it and go ahead with the disk creation wizard (this process still remains almost same except the storage account selection part).
 
 

So, as described above,  the VM with unmanaged disks can be converted to managed VM with managed disks.
 
Reference
 
You can learn details of various scenarios and processes here.


Similar Articles