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 $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
}
0 comments
Hide comments