What is Availability Set in Azure: Explanation and Example
Availability Set in Azure is a way to group virtual machines to ensure they stay available during planned or unplanned maintenance. It spreads VMs across multiple physical servers, racks, and power sources to reduce downtime and increase reliability.How It Works
Think of an Availability Set like a safety net for your virtual machines (VMs). When you put VMs in an availability set, Azure makes sure they are placed on different physical hardware. This means if one server or rack has a problem, not all your VMs go down at once.
Azure uses two main ideas: Fault Domains and Update Domains. Fault Domains are like different power circuits or racks in a data center. Update Domains are groups that get updated or rebooted at different times. By spreading VMs across these domains, Azure keeps your service running smoothly even during maintenance or hardware failures.
Example
This example shows how to create an Availability Set and add two VMs to it using Azure CLI commands.
az group create --name MyResourceGroup --location eastus az availability-set create --resource-group MyResourceGroup --name MyAvailabilitySet --platform-fault-domain-count 2 --platform-update-domain-count 2 az vm create --resource-group MyResourceGroup --name VM1 --availability-set MyAvailabilitySet --image UbuntuLTS --admin-username azureuser --generate-ssh-keys az vm create --resource-group MyResourceGroup --name VM2 --availability-set MyAvailabilitySet --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
When to Use
Use an Availability Set when you want to make sure your application stays online even if Azure performs maintenance or if hardware fails. It is ideal for critical apps that need high uptime but run on multiple VMs.
For example, if you run a website on several VMs, putting them in an availability set helps keep the site available during updates or unexpected problems. It is also useful for databases or services that require continuous operation.
Key Points
- An Availability Set groups VMs to improve uptime.
- It uses fault domains and update domains to spread VMs.
- It protects against hardware failures and maintenance downtime.
- It is best for multi-VM applications needing high availability.