Bird
Raised Fist0
Azurecloud~5 mins

Availability sets for redundancy in Azure - Commands & Configuration

Choose your learning style10 modes available
Introduction
When you run apps on cloud servers, sometimes a server can fail or need maintenance. Availability sets help keep your app running by spreading your servers across different groups so not all fail at once.
When you want to keep your website running even if one server has a problem.
When you deploy multiple virtual machines that need to stay available during updates.
When you want to avoid downtime caused by hardware failures in the cloud.
When you need to meet a service level agreement that requires high uptime.
When you want to balance your app's servers across different physical racks in the data center.
Config File - availability-set.json
availability-set.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Compute/availabilitySets",
      "apiVersion": "2022-03-01",
      "name": "myAvailabilitySet",
      "location": "eastus",
      "properties": {
        "platformFaultDomainCount": 2,
        "platformUpdateDomainCount": 5
      },
      "sku": {
        "name": "Aligned"
      }
    }
  ]
}

This JSON file is an Azure Resource Manager (ARM) template that creates an availability set named myAvailabilitySet in the eastus region.

platformFaultDomainCount sets how many separate physical racks your servers will be spread across to avoid hardware failures affecting all at once.

platformUpdateDomainCount sets how many groups your servers are divided into for updates, so not all update at the same time.

The sku with value Aligned means it uses the latest Azure infrastructure for availability sets.

Commands
Create a resource group to hold your availability set and other resources. This groups them together for easy management.
Terminal
az group create --name myResourceGroup --location eastus
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup", "location": "eastus", "managedBy": null, "name": "myResourceGroup", "properties": { "provisioningState": "Succeeded" }, "tags": {}, "type": "Microsoft.Resources/resourceGroups" }
→
--name - Sets the name of the resource group.
→
--location - Specifies the Azure region for the resource group.
Deploy the availability set using the ARM template file you created. This sets up the redundancy groups in Azure.
Terminal
az deployment group create --resource-group myResourceGroup --template-file availability-set.json
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/deployment1", "name": "deployment1", "properties": { "provisioningState": "Succeeded", "outputs": {} }, "resourceGroup": "myResourceGroup", "timestamp": "2024-06-01T12:00:00Z", "templateLink": null, "mode": "Incremental" }
→
--resource-group - Specifies the resource group where the deployment happens.
→
--template-file - Points to the ARM template file to deploy.
Create a virtual machine named myVM1 inside the availability set to ensure it benefits from redundancy.
Terminal
az vm create --resource-group myResourceGroup --name myVM1 --image UbuntuLTS --availability-set myAvailabilitySet --admin-username azureuser --generate-ssh-keys
Expected OutputExpected
{ "fqdns": "", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1", "location": "eastus", "name": "myVM1", "powerState": "VM running", "privateIpAddress": "10.0.0.4", "publicIpAddress": "52.170.12.34", "resourceGroup": "myResourceGroup", "zones": null }
→
--availability-set - Assigns the VM to the availability set for redundancy.
→
--generate-ssh-keys - Automatically creates SSH keys for secure login.
List all virtual machines in the resource group with details to verify the VM is created and part of the availability set.
Terminal
az vm list --resource-group myResourceGroup --show-details --output table
Expected OutputExpected
Name ResourceGroup Location Zones PowerState PublicIps PrivateIps ------ --------------- ---------- ------- ------------ ----------- ----------- myVM1 myResourceGroup eastus VM running 52.170.12.34 10.0.0.4
→
--show-details - Shows extra info like power state and IP addresses.
→
--output - Formats the output as a readable table.
Key Concept

If you remember nothing else from this pattern, remember: availability sets keep your app running by spreading servers across different physical and update groups to avoid single points of failure.

Common Mistakes
Creating virtual machines without assigning them to the availability set.
The VMs won't be protected by the availability set, so they can all fail or update at the same time.
Always use the --availability-set flag when creating VMs to include them in the availability set.
Setting platformFaultDomainCount or platformUpdateDomainCount to 1.
This means no real spreading across racks or update groups, so redundancy is lost.
Use at least 2 fault domains and multiple update domains for proper redundancy.
Summary
Create a resource group to organize your cloud resources.
Deploy an availability set using an ARM template to define fault and update domains.
Create virtual machines inside the availability set to ensure redundancy.
Verify the VMs are running and part of the availability set with Azure CLI commands.

Practice

(1/5)
1. What is the main purpose of an Availability Set in Azure?
easy
A. To automatically back up virtual machines every hour
B. To keep virtual machines running during hardware failures by spreading them across fault domains
C. To increase the storage capacity of a single virtual machine
D. To reduce the cost of virtual machines by sharing resources

Solution

  1. Step 1: Understand the role of Availability Sets

    Availability sets distribute VMs across different physical hardware to avoid single points of failure.
  2. Step 2: Identify the correct purpose

    This distribution helps keep apps running during hardware failures by using fault domains.
  3. Final Answer:

    To keep virtual machines running during hardware failures by spreading them across fault domains -> Option B
  4. Quick Check:

    Availability sets = fault domain distribution [OK]
Hint: Availability sets protect VMs from hardware failure by spreading them [OK]
Common Mistakes:
  • Confusing availability sets with backup solutions
  • Thinking availability sets increase storage
  • Assuming availability sets reduce VM costs
2. Which of the following is the correct way to create an availability set using Azure CLI?
easy
A. az vm availability-set create --name MySet --resource-group MyGroup --platform-fault-domain-count 2 --platform-update-domain-count 5
B. az availability-set create --name MySet --group MyGroup --faults 2 --updates 5
C. az vm create availability-set --name MySet --resource-group MyGroup --fault-domain 2 --update-domain 5
D. az create availability-set --name MySet --resource MyGroup --fault-domain-count 2 --update-domain-count 5

Solution

  1. Step 1: Recall Azure CLI syntax for availability sets

    The correct command uses az vm availability-set create with parameters for fault and update domain counts.
  2. Step 2: Match the correct command

    az vm availability-set create --name MySet --resource-group MyGroup --platform-fault-domain-count 2 --platform-update-domain-count 5 matches the correct syntax and parameter names exactly.
  3. Final Answer:

    az vm availability-set create --name MySet --resource-group MyGroup --platform-fault-domain-count 2 --platform-update-domain-count 5 -> Option A
  4. Quick Check:

    Correct CLI syntax = az vm availability-set create --name MySet --resource-group MyGroup --platform-fault-domain-count 2 --platform-update-domain-count 5 [OK]
Hint: Use 'az vm availability-set create' with fault and update domain counts [OK]
Common Mistakes:
  • Using wrong command group like 'az availability-set create'
  • Incorrect parameter names like 'faults' or 'updates'
  • Mixing VM creation command with availability set creation
3. Given an availability set with 3 fault domains and 5 update domains, what happens if a planned maintenance affects update domain 3?
medium
A. All VMs are shut down until maintenance completes
B. All VMs in the availability set reboot simultaneously
C. VMs in fault domain 3 are rebooted, others are unaffected
D. Only VMs in update domain 3 are rebooted; others keep running

Solution

  1. Step 1: Understand update domains in availability sets

    Update domains define groups of VMs rebooted one group at a time during planned maintenance.
  2. Step 2: Apply update domain behavior

    Only VMs in the affected update domain reboot; others continue running.
  3. Final Answer:

    Only VMs in update domain 3 are rebooted; others keep running -> Option D
  4. Quick Check:

    Update domain reboot = only affected domain [OK]
Hint: Update domains reboot one group at a time during maintenance [OK]
Common Mistakes:
  • Confusing fault domains with update domains
  • Assuming all VMs reboot together
  • Thinking fault domain 3 is rebooted on update domain maintenance
4. You created two VMs but forgot to assign them to the same availability set. What is the likely impact?
medium
A. The VMs may be placed on the same hardware, increasing downtime risk
B. The VMs will automatically be grouped into a default availability set
C. The VMs will not start until assigned to an availability set
D. The VMs will be backed up automatically to prevent downtime

Solution

  1. Step 1: Understand VM placement without availability sets

    Without an availability set, Azure may place VMs on the same physical hardware.
  2. Step 2: Identify impact on redundancy

    This increases risk that a hardware failure affects both VMs, causing downtime.
  3. Final Answer:

    The VMs may be placed on the same hardware, increasing downtime risk -> Option A
  4. Quick Check:

    No availability set = no guaranteed hardware separation [OK]
Hint: Without availability sets, VMs risk being on same hardware [OK]
Common Mistakes:
  • Assuming Azure auto-creates availability sets
  • Thinking VMs won't start without availability sets
  • Confusing availability sets with backup features
5. You need to deploy 6 VMs with high availability. You create an availability set with 2 fault domains and 3 update domains. What is the best way to distribute the VMs to maximize redundancy?
hard
A. Place 2 VMs in fault domain 1 and 4 VMs in fault domain 2, all in update domain 1
B. Place all 6 VMs in fault domain 1 to simplify management
C. Place 3 VMs in fault domain 1 and 3 VMs in fault domain 2, spread evenly across update domains
D. Place all VMs in the same update domain to reduce reboot frequency

Solution

  1. Step 1: Understand fault domain distribution

    Fault domains separate VMs across different hardware racks to avoid single points of failure.
  2. Step 2: Understand update domain distribution

    Update domains ensure VMs reboot in groups during maintenance, so spreading VMs across them reduces downtime.
  3. Step 3: Apply best practice for VM distribution

    Distributing VMs evenly across fault domains and update domains maximizes redundancy and availability.
  4. Final Answer:

    Place 3 VMs in fault domain 1 and 3 VMs in fault domain 2, spread evenly across update domains -> Option C
  5. Quick Check:

    Even VM spread across fault and update domains = max redundancy [OK]
Hint: Distribute VMs evenly across fault and update domains for best uptime [OK]
Common Mistakes:
  • Putting all VMs in one fault domain
  • Ignoring update domain distribution
  • Assuming same update domain reduces reboots
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard