Switching to managed disks for Availability Set

Switching to managed disks for Availability Set

Q. I have an Availability Set and want to switch to managed disks, how do I do this?

A. A simple way to switch all VMs to managed disks (which will ensure separate storage clusters are used for each fault domain increasing resiliency) is to run the PowerShell below (change the resource group and availability set name):

$rgName = 'RGEastUSMinecraft'

$avSet = Get-AzureRmAvailabilitySet -ResourceGroupName $rgName -Name $avSetName
Update-AzureRmAvailabilitySet -AvailabilitySet $avSet -Sku Aligned

foreach($vmInfo in $avSet.VirtualMachinesReferences)
    $vm = Get-AzureRmVM -ResourceGroupName $rgName | Where-Object {$_.Id -eq $vmInfo.id}
    Write-Output $vm.Name 
    Stop-AzureRmVM -ResourceGroupName $rgName -Name $vm.Name -Force
    ConvertTo-AzureRmVMManagedDisk -ResourceGroupName $rgName -VMName $vm.Name


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.