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.

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:



1 2 3 4 5 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:



1 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:



1 $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.

Subscribe to Petri Newsletters Office 365 Insider Our Petri Office 365 Insider is dedicated to sharing detailed knowledge from top Office 365 experts. Delivered once a month to your inbox. All Newsletters Petri.com may use your contact information to provide updates, offers and resources that may be of interest to you. You can unsubscribe at any time. To learn more about how we manage your data, you can read our Privacy Policy and Terms of Service. !Already a Petri.com member? Login here for 1-click registration.

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:



1 $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:



1 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.