How to convert Azure VM to use managed disks

Did you ever hear about Azure managed disks? Do you know how to convert Azure VM to use managed disks?
If for both question your answer is no, let me help you to explain what managed disks are and for which purpose they are use.

Managed disks are new type of storage which is recommended to be used by Azure Virtual Machines.
Managed Disks offer two types of storage options: Premium and Standard Managed Disks.
Check Managad Disks pricing under below link.

If you decide to convert Azure VM to use Managed Disks, you can use simple script which is provided below.
The most important thing in the script is installation of AzureRM.Compute module.
Be sure that you have the newest version of this module installed.

Install-Module -Name AzureRM.Compute -RequiredVersion 3.1.0 -AllowClobber

Configuration of Azure Virtual Machine before converting:

Before converting script must stop Azure VM, please ensure that you save all necessary information before run it!

Script:

Install-Module -Name AzureRM.Compute -RequiredVersion 3.1.0 -AllowClobber

$SubscriptionID = "Subscription ID"
$ResourceGroupName = "RG_Name"
$VMName = "VMName"

Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId $SubscriptionID

Stop-AzureRmVM -Name $VMName -ResourceGroupName $ResourceGroupName -Force
Write-Host "Machine $VMName has been stopped."

ConvertTo-AzureRmVMManagedDisk -ResourceGroupName $ResourceGroupName -VMName $VMName
Write-Host "Converting to Managed Disk completed."

Start-AzureRMVM -Name $VMName -ResourceGroupName $ResourceGroupName
Write-Host "Machine $VMName has been started."

Configuration of Azure Virtual Machine after converting:

Now you don’t need to use storage accounts for Azure Virtual machines 🙂
If you have any question regarding this topic don’t hesitate to leave a comment.

I hope it will be usefull for some of you 🙂
Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.