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

Passwords Haven’t Disappeared Yet

123456. Qwerty. Iloveyou. No, these are not exercises for people who are brand new to typing. Shockingly, they are among the most common passwords that end users choose in 2021. Research has found that the average business user must manually type out, or copy/paste, the credentials to 154 websites per month. We repeatedly got one question that surprised us: “Why would I ever trust a third party with control of my network?


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.
13 Email Threat Types to Know About Right Now

As email threats evolve and multiply, keeping track of them all—and staying protected against the many different types—becomes a complex challenge. Today, that requires more than just the traditional email gateway solution that used to be good enough.

In this eBook you will learn:

  • What are the most common and challenging email attacks for organizations?
  • How to defend against sophisticated email threats, such as spoofing, social engineering, and fraud
  • How to protect employees at the inbox level with the right technologies and security-awareness training
  • How to use a multilayered protection strategy to reduce susceptibility to email attacks and better defend your business and employees

Sponsored by: