Hi all,

One of the limitations we may encounter when dealing with Azure ARM Virtual Machines is the ability to manipulate the VM’s availability Set configuration after the VM deployment. In fact:

  • You can’t change the VM’s Availability Set once the VM is created
  • You can’t add an Azure VM to an Availability Set once the VM is created
  • You can’t remove a VM from an Availability Set

This is a big limitation since we may need such feature, in different cases:

  • We need to add an existing VM to a highly available pool
  • We want to change the Availability Set name
  • We messed up with the Availability Set  naming

This feature will come in the future, but the far or the near future, we have no idea. Maybe by the end of the year (Q4!)

Till that time, this Powershell script enables you to manage an ARM VM’s availability Set.


  • Add a VM to an Availability Set
  • Change a VM’s Availability Set
  • Remove a VM from an Availability Set

How it works?

The script will:

  1. Get the VM configuration
  2. Save it to a local location (if something goes wrong, we can recreate the VM)
  3. Remove the VM (Only the configuration, all related objects are kept)
  4. Create a new  VM configuration with the AS config (Add AS, Remove AS, Change AS)
  5. Recreate the VM

How to use it?

1. Download the script and save it to local location

2. Run it and provide the requested parameters


2. ./Set-ArmVmAvailabilitySet.ps1 –VmName ‘The VM Name’ –ResourceGroup ‘Resource Group’ –AvailabilitySetName ‘As Name’ –SubscriptionName  ‘The Subscription name’


To remove a VM from an AvailabilitySet:

./Set-ArmVmAvailabilitySet.ps1 –VmName ‘The VM Name’ –ResourceGroup ‘Resource Group’ –AvailabilitySetName 0 –SubscriptionName  ‘The Subscription name’


Download Link

Version 1.01: https://gallery.technet.microsoft.com/Set-Azure-Resource-Manager-f7509ec4

Version 1.0: (Retired)