Switching to managed disks for Availability Set

Switch an Availability Set to use managed disks.

John Savill

July 10, 2017

1 Min Read
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'$avSetName = 'ASEASTUSWEBSRV'$avSet = Get-AzureRmAvailabilitySet -ResourceGroupName $rgName -Name $avSetNameUpdate-AzureRmAvailabilitySet -AvailabilitySet $avSet -Sku Alignedforeach($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}

 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like