VM Availability Sets
Complete the full lesson to earn 25 points
Work through each section, then tap “Mark as Complete” on the last one.
Understanding Azure Availability Sets: A Deep Dive into VM Reliability
Introduction: Why Availability Sets Matter
In the world of cloud computing, hardware failure is not a matter of "if," but "when." Even with the massive scale and sophisticated engineering of Microsoft Azure, physical servers, network switches, and power supplies eventually reach the end of their life cycles or experience unexpected faults. When you deploy a virtual machine (VM) in Azure, your application is inherently tied to the physical hardware running that VM. If the underlying host server goes down for maintenance or hardware failure, your application will experience downtime.
For mission-critical applications, this downtime is often unacceptable. This is where Azure Availability Sets come into play. An Availability Set is a logical grouping capability that you can use to ensure that the VM resources you place within it are isolated from each other when they are deployed within an Azure datacenter. By spreading your VMs across multiple physical hardware nodes, you ensure that at least one instance of your application remains operational even during planned maintenance or unplanned hardware failures.
Understanding Availability Sets is fundamental to designing for high availability in Azure. It is the first line of defense for IaaS (Infrastructure as a Service) workloads. Without proper configuration of availability features, your application's uptime is entirely dependent on the health of a single physical server rack. This lesson will guide you through the mechanics, configuration, and best practices of using Availability Sets to build a resilient cloud architecture.
The Core Concepts: Fault Domains and Update Domains
To understand how Availability Sets work, you must understand the two primary mechanisms they employ: Fault Domains and Update Domains. These are the "secret sauce" that allows Azure to provide uptime guarantees for your VMs.
Fault Domains
A Fault Domain defines a group of VMs that share a common power source and a common network switch. Think of a Fault Domain as a physical server rack within an Azure datacenter. If you place your VMs in the same Fault Domain, they are all susceptible to the same physical failure—such as a power supply blowing out or a top-of-rack switch failing.
When you create an Availability Set, Azure automatically distributes your VMs across multiple Fault Domains. By default, Azure typically provides three Fault Domains in most regions. If you have three VMs in an Availability Set, Azure will place each VM in a different rack. If one rack loses power, only one of your VMs goes offline, while the other two remain healthy and serving traffic.
Update Domains
Update Domains represent a group of VMs and underlying physical hardware that can be rebooted at the same time. During scheduled Azure maintenance—such as security patching or firmware updates—Azure does not take down all your infrastructure at once. Instead, it processes the updates in batches.
These batches are the Update Domains. When you assign your VMs to an Availability Set, Azure automatically assigns them to different Update Domains. If you have five Update Domains and five VMs, Azure will only update one VM at a time. This ensures that you always have the majority of your application instances running during maintenance windows.
Callout: Fault Domains vs. Update Domains It is common to confuse these two concepts. Remember this simple distinction: Fault Domains are about hardware failure (unplanned events), while Update Domains are about maintenance (planned events). A Fault Domain protects you from a power outage or switch failure, whereas an Update Domain protects you from the impact of necessary software or firmware updates performed by the Azure platform team.
Configuring Availability Sets: A Practical Approach
Implementing an Availability Set is a straightforward process, but it must be done at the time of VM creation. You cannot add an existing, standalone VM into an Availability Set after it has been deployed. If you have an existing VM and decide you need higher availability, you would typically need to recreate the VM as part of an Availability Set or migrate it to a different availability model like Virtual Machine Scale Sets.
Step-by-Step: Creating an Availability Set via Azure Portal
- Navigate to the Resource Group: Choose the Resource Group where you intend to house your VMs.
- Create the Availability Set: Click "Create" and search for "Availability Set." Fill in the required details, such as the Name, Region, and Subscription.
- Configure Fault and Update Domains: Under the "Configuration" tab, select the number of Fault Domains (usually 2 or 3) and Update Domains (up to 20).
- Deploy VMs: When creating a new Virtual Machine, navigate to the "Availability options" section under the "Basics" tab. Select "Availability set" from the dropdown menu and choose the set you just created.
Using Azure CLI for Deployment
For those who prefer infrastructure-as-code or command-line interfaces, the Azure CLI provides a concise way to manage these resources.
# Create a resource group
az group create --name MyResourceGroup --location eastus
# Create the Availability Set
az vm availability-set create \
--name MyAvailabilitySet \
--resource-group MyResourceGroup \
--platform-fault-domain-count 2 \
--platform-update-domain-count 5
# Create a VM and add it to the Availability Set
az vm create \
--resource-group MyResourceGroup \
--name MyVM1 \
--availability-set MyAvailabilitySet \
--image Ubuntu2204 \
--admin-username azureuser \
--generate-ssh-keys
In the example above, we explicitly defined 2 fault domains and 5 update domains. This provides a balanced configuration for a small cluster of VMs.
Note: The
platform-update-domain-countcan be set up to 20. Increasing this number means your maintenance windows will be slower (as fewer VMs are patched at once), but it provides a smoother experience because a smaller percentage of your fleet is undergoing maintenance at any given time.
Best Practices for High Availability
Simply putting VMs into an Availability Set is not enough to guarantee your application stays online. You must combine this infrastructure configuration with architectural patterns that support redundancy.
1. Load Balancing is Mandatory
An Availability Set is just a container; it does not provide traffic management. If you have two web servers in an Availability Set and one goes down, your users will still hit a dead end if they try to access the failed instance. You must place an Azure Load Balancer in front of your Availability Set to distribute traffic only to the healthy instances.
2. Implement Health Probes
The Load Balancer needs to know which VMs are actually healthy. Configure health probes that check a specific endpoint on your application (e.g., /health). If the application crashes on a VM, the probe will fail, and the Load Balancer will automatically stop sending traffic to that specific VM until it recovers.
3. Distribute Workloads Evenly
If you have four VMs, try to keep your distribution consistent across your Fault Domains. While Azure handles the initial placement, you should avoid "stacking" critical components on the same VM if you have the capacity to scale out.
4. Use Managed Disks
Always use Managed Disks for VMs in an Availability Set. Managed Disks are automatically isolated from each other in terms of storage performance and fault boundaries. This prevents a single storage failure from impacting all your VMs simultaneously.
5. Monitor Infrastructure Health
Use Azure Monitor to track the health of your Availability Set. If a VM fails, you should receive an alert. Furthermore, check the "Scheduled Events" service within your VM. Azure provides a metadata service that warns your application 15 minutes before a reboot occurs due to maintenance. Your application can use this signal to drain connections or save state before the reboot happens.
Common Pitfalls and How to Avoid Them
Even experienced architects can fall into traps when dealing with Availability Sets. Here are the most common mistakes:
Mistake 1: Placing "All Eggs in One Basket"
Sometimes, teams create an Availability Set but only put one VM in it. This provides zero redundancy. An Availability Set only protects you if you have at least two instances. If you cannot afford to run two VMs, you should not be using an Availability Set; instead, you should focus on automated backups and fast recovery processes.
Mistake 2: Ignoring the "Same Region" Constraint
An Availability Set is bound to a specific region. You cannot span an Availability Set across multiple Azure regions (e.g., East US and West US). If you require disaster recovery across geographic locations, you need to use Site Recovery or deploy separate sets in each region and use a Global Load Balancer like Azure Front Door or Traffic Manager.
Mistake 3: Misunderstanding the SLA
Many users assume an Availability Set provides a "100% uptime" guarantee. It does not. The Azure Service Level Agreement (SLA) for VMs in an Availability Set is typically 99.95%. This means you can still experience up to about 21 minutes of downtime per month. If your business requires 99.99% or higher, you need to look at Availability Zones or higher-level services like App Service or Kubernetes.
Warning: Do not confuse Availability Sets with Availability Zones. Availability Zones provide protection against entire datacenter failures (physical buildings), whereas Availability Sets only protect against rack-level failures within a single datacenter. If a natural disaster hits the entire datacenter, an Availability Set will go down entirely.
Comparison: Availability Sets vs. Availability Zones vs. Scale Sets
To help clarify where Availability Sets fit into the broader Azure ecosystem, refer to the following comparison table:
| Feature | Availability Sets | Availability Zones | Virtual Machine Scale Sets |
|---|---|---|---|
| Primary Goal | Rack-level redundancy | Datacenter-level redundancy | Horizontal scaling |
| Fault Protection | Hardware/Rack failure | Datacenter/Building failure | Both (depends on config) |
| SLA | 99.95% | 99.99% | 99.95% to 99.99% |
| Complexity | Low | Medium | High |
| Best For | Legacy apps, simple clusters | High-availability production | Auto-scaling workloads |
As you can see, Availability Sets are the "entry-level" high availability feature. They are ideal for applications that aren't built to be cloud-native or for simple two-tier architectures that just need a bit of extra protection from hardware hiccups.
Advanced Scenarios: Managing Maintenance
One of the most powerful features of Azure is how it handles maintenance. Because Azure is a massive multi-tenant environment, the platform team must constantly update the host OS and hardware drivers.
When you use an Availability Set, you can view the maintenance status of your VMs through the Azure portal or CLI. If you are running a database cluster, you might want to know exactly when a node is going to be rebooted so you can manually failover the primary role to a different node before the maintenance begins.
Example: Using Scheduled Events
You can query the Azure Metadata Service from within your VM to see if a maintenance event is pending:
curl -H Metadata:true http://169.254.169.254/metadata/scheduledevents?api-version=2020-07-01
If the response returns an event with a NotStarted status, your application can trigger a script to:
- Stop the application services.
- Flush caches to disk.
- Signal the load balancer to remove this node from the rotation.
- Allow the maintenance to proceed.
This level of orchestration is what separates high-performing, resilient applications from those that suffer from "random" failures.
Implementation Checklist
Before you deploy your next production workload, run through this checklist to ensure your Availability Set is configured correctly:
- Redundancy: Do I have at least two VMs in this set?
- Load Balancing: Is there a load balancer or application gateway in front of these VMs?
- Health Probes: Are the probes configured to monitor the actual application port, not just the VM's ping?
- Disk Strategy: Am I using Managed Disks to ensure storage fault isolation?
- Maintenance Awareness: Does my application handle sudden reboots gracefully, or do I need to implement a scheduled event listener?
- Region Alignment: Is this the right region for my user base?
- Scale Strategy: If the load increases, how will I handle it? (If you need to scale, consider transitioning to Virtual Machine Scale Sets).
Addressing Common Questions (FAQ)
Can I move an existing VM into an Availability Set?
No. You must create a new VM and place it in the Availability Set. You can, however, take a snapshot of the existing VM's disk, create a managed disk from that snapshot, and then create a new VM using that disk within the Availability Set.
Why does Azure suggest I use Availability Zones instead?
Availability Zones are the newer standard. They provide protection against the failure of an entire datacenter building, which is a much higher level of protection than an Availability Set. Unless you have a specific technical reason to use Availability Sets (such as latency requirements between VMs that are only met by being in the same datacenter), you should prioritize Availability Zones.
Can I have different VM sizes in an Availability Set?
Yes, you can mix and match VM sizes within an Availability Set. However, it is generally recommended to keep them similar so that your application performance remains consistent across all nodes.
What happens if I reach the limit of my Fault Domains?
Azure will prevent you from adding more VMs to that specific Availability Set if you exceed the physical capacity of the underlying hardware for that configuration. This is why it is important to plan your capacity ahead of time.
Summary and Key Takeaways
As we conclude this lesson on VM Availability Sets, it is important to synthesize the core pillars of what we have covered. Availability Sets are not just a check-box feature; they are a critical component of your disaster recovery and uptime strategy.
- Hardware Failure is Inevitable: Always assume that the underlying physical hardware will fail. Use Availability Sets to ensure that your application is not running on a single point of failure.
- Fault Domains Provide Physical Isolation: By automatically spreading VMs across different racks, switches, and power sources, you insulate your service from localized hardware outages.
- Update Domains Manage Maintenance: Azure’s patching process is designed to be non-disruptive, provided you have configured your VMs into an Availability Set to allow for rolling updates.
- Availability Sets Are Not Enough Alone: You must pair your Availability Sets with Load Balancers, health probes, and robust application design to ensure that the infrastructure actually reacts to failures in the way you expect.
- Plan for the Future: While Availability Sets are excellent for many scenarios, always evaluate if Availability Zones or Virtual Machine Scale Sets are a better fit for your specific scaling and reliability requirements.
- Infrastructure as Code: Always deploy your Availability Sets using templates or scripts (CLI, PowerShell, Terraform) to ensure consistency across your development, test, and production environments.
- Monitor, Monitor, Monitor: Use Azure metrics and scheduled events to keep a pulse on the health and maintenance status of your VMs. A well-informed administrator can prevent a minor maintenance event from becoming a major service outage.
By mastering Availability Sets, you take a significant step toward becoming a proficient Azure architect. You are moving beyond simply "making it work" to "making it last," ensuring that the services you deploy are capable of weathering the storms of cloud infrastructure volatility. Take these principles, apply them to your test environments, and always build with the assumption that your hardware will eventually need to be replaced or repaired. Your users will appreciate the stability, and you will gain the peace of mind that comes with a well-engineered, resilient system.
Continue the course
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles your daily points limit so you progress twice as fast, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× daily points limit
- ✓ Distraction-free lessons