Availability Set can be used to increase the reliability and availability of Virtual Machines within Azure. These ensure that any VM deployed to Azure within an availability set is hosted across multiple multiple physical servers, compute racks, storage units, and network switches that are isolated from each other.
The benefit of using availability sets is that any hardware or software failure within Azure or restart of VM due to Azure maintenance will only impact a subset of VM and the overall solution stays available and operational. For example, if an organization is hosting their Domain Controller as a VM within then having a minimum of two within an availability set will mean that if one goes down then the other can still provide domain services to any server that rely on it. If there is only a single DC or they are not in an availability set then an outage of Domain Services can happen.
Virtual Machines must be created within an availability set, VMs are not able to be added to an availability set after creation. When a VM is created within an availability set Azure guarantees to spread them across Fault Domains and Update Domains.
A Fault Domain (FD) is essentially a rack of servers which consumes subsystems like network, power, cooling etc. Therefore two VMs in the same availability set means that Azure will provision them into two different racks so that if the network or the power failed, only one rack would be affected. By default, VMs configured within an availability set are separated across up to three fault domains for Resource Manager deployments.
An Update Domain (UD) is a group of VMs and underlying physical hardware that can be rebooted at the same time for maintenance. Five non-user-configurable update domains are assigned by default but this can be increased to provide up to 20 update domains. The order of update domains being rebooted may not proceed sequentially during planned maintenance, but only one update domain is rebooted at a time. A rebooted update domain is given 30 minutes to recover before maintenance is initiated on a different update domain. Reference
Creating a VM within an availability set – Portal
To create a virtual machine within an availability set, upon creation select ‘Availability Set’ under Availability Option and then select the availability set name or create a new one as required.
Creating a VM within an availability set – ARM template
Availability set can be defined within an ARM template, below is a snippet of an ARM template show the availability set settings