Applies to: ✔️ Linux VMs ✔️ Windows VMs
The following steps describe how to change the availability set of a VM using Azure PowerShell. A VM can only be added to an availability set when it is created. To change the availability set, you need to delete and then recreate the virtual machine.
This article was last tested on 2/12/2019 using the Azure Cloud Shell and the Az PowerShell module version 1.2.0.
Warning
This is just an example and in some cases it will need to be updated for your specific deployment.
Make sure the disks are set to detach
as the delete option. If they are set to delete
, update the VMs before deleting the VMs.
If your VM is attached to a load balancer, you will need to update the script to handle that case.
Some extensions may also need to be reinstalled after you finish this process.
If your VM uses hybrid benefits, you will need to update the example to enable hybrid benefits on the new VM.