Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET
Cloud Computing

What Are Azure Managed Disks?

In today’s Ask the Admin, I’ll look at how Microsoft is making it easier to provision disks in Azure.

Azure Storage provides scalable, durable, and highly available storage, and to facilitate this, there are two types of storage account that can be used to provision blob, table, queue, file storage, and virtual machine (VM) hard disks. Until recently, creating a virtual disk in the Azure cloud required working directly with a storage account, but Managed Disks can be created while leaving Azure to create and manage the necessary storage account.


Sponsored Content

Say Goodbye to Traditional PC Lifecycle Management

Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.


In more complex scenarios, such as using Virtual Machine Scale Sets (VMSS) to create thousands of identical VMs, Managed Disks automate storage account scale management. Managed Disks now allow VMSS to scale up to one thousand VMs in a single set, 10 times more than was possible with unmanaged disks.

Managed Disks are Azure Resource Manager (ARM) resources, and as such can be managed using JSON templates. As part of this release, Snapshots and Images are also now ARM resources. For more information on working with ARM templates, see What are Microsoft Azure Resource Groups? and Export Azure Resource Group as a JSON Template on the Petri IT Knowledgebase. But probably the best news is that existing ARM VMs can be converted to Managed Disks with just a reboot.

For more information on creating VMs in Azure, see Create a Virtual Machine in the Azure Cloud on Petri.

Unmanaged vs. Managed Disks

Let’s have a look at how the process of using a Managed Disk for a VM differs in PowerShell. When using unmanaged disks, you first need to create a storage account, using the New-AzureRmStorageAccount cmdlet, and a URI for the OS disk:

New-AzureRmStorageAccount -Name $storaccName -ResourceGroupName $rgName –Type 'Standard_LRS' -Location $location

$storacct = Get-AzureRmStorageAccount -ResourceGroupName $rgName –StorageAccountName $storaccName 
$disknameOS = $vmname + 'diskOS' 
$vhduri = $storacct.PrimaryEndpoints.Blob.ToString() + "vhds/${disknameOS}.vhd"

And finally, set the OS disk for the new VM using Set-AzureRmVMOSDisk:
Set-AzureRmVMOSDisk -VM $newVM -Name $disknameOS -VhdUri $vhduri -Caching ReadWrite -CreateOption fromImage

Managed Disks

But using Managed Disks, we can skip the process of creating a storage account and defining a URI for the disk. All we need to do is specify the disk name, storage account type, and a few other parameters:

$myVM = Set-AzureRmVMOSDisk -VM $myVM -Name 'myOsDisk1' -StorageAccountType PremiumLRS -DiskSizeInGB 128 -CreateOption FromImage -Caching ReadWrite

The VM can then be provisioned using the New-AzureRmVM cmdlet. For a complete guide to deploying ARM VMs using PowerShell, see Deploy VMs Using Azure Resource Manager and PowerShell on Petri.

Convert a VM to Managed Disks

Existing ARM VMs in your Azure subscription can be converted to Managed Disks using the ConvertTo-AzureRmVMManagedDisk cmdlet. First, stop the VM you want to convert using the code below, replacing myResourceGroup and myVM with a resource group and VM name as appropriate:

$rgName = 'myResourceGroup' $vmName = 'myVM' Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Force

Once the status of the VM has changed to Stopped (Deallocated), use ConvertTo-AzureRmVMManagedDisk to convert all disks associated with the VM to Managed Disks:
ConvertTo-AzureRmVMManagedDisk -ResourceGroupName $rgName -VMName $vmName

In this article, I explained how Azure Managed Disks differ from unmanaged disks and how to convert existing ARM VMs to Managed Disks.

Related Topics:


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (0)

Leave a Reply

IT consultant, Contributing Editor @PetriFeed, and trainer @Pluralsight. All about Microsoft, Office 365, Azure, and Windows Server.