Skip to content

Availability

Lab Objective

In this hands-on lab, you will learn how to:

  • Deploy VMs to availability zones across three separate datacenters for maximum resilience
  • Create availability sets with fault and update domains for traditional high availability
  • Configure load balancers to distribute traffic across multiple VM instances
  • Test failover scenarios by stopping VMs and observing traffic redirection
  • Set up basic monitoring to track VM availability and performance

Scenario: Deploy a web application across multiple availability zones with automatic failover to ensure high availability.


Pre-Provisioned Environment

Resource TypeResource NamePurpose
Resource GroupAvailability-Lab-RGContains all lab resources
Virtual Networkavailability-vnetNetwork for VMs (10.0.0.0/16)
Load Balanceravail-lb[unique]Distributes traffic across VMs
Public IPavail-pip[unique]External access to load balancer

Lab Exercises

Part 1: Deploy VMs to Availability Zones

Step 1: Create First VM in Zone 1

  1. Navigate to Virtual machinesCreate
  2. Select Availability-Lab-RG resource group
  3. Set VM name: WebVM-Zone1
  4. Choose Windows Server 2019 Datacenter
  5. Select size: Standard_B2s
  6. Set administrator username: azureuser
  7. Set administrator password: Password123!

Step 2: Configure Availability Zone

  1. Click “Availability options”
  2. Select “Availability zone”
  3. Choose “Zone 1”
  4. Click “Next: Disks”

Step 3: Configure Networking

  1. Select virtual network: availability-vnet
  2. Create new subnet: zone1-subnet (10.0.1.0/24)
  3. Select “Create new” public IP
  4. Click “Review + create” → Create

Step 4: Create VMs in Other Zones

  1. Repeat the process to create:
    • WebVM-Zone2 in Availability Zone 2 (subnet: 10.0.2.0/24)
    • WebVM-Zone3 in Availability Zone 3 (subnet: 10.0.3.0/24)

Verify: Check that all three VMs are created in different availability zones.


Part 2: Configure Load Balancer

Step 1: Add VMs to Backend Pool

  1. Navigate to Load balancersavail-lb[unique]
  2. Go to SettingsBackend pools
  3. Click the existing backend pool
  4. Add all three VMs (WebVM-Zone1, WebVM-Zone2, WebVM-Zone3)
  5. Click “Save”

Step 2: Configure Health Probe

  1. Go to SettingsHealth probes
  2. Click “Add”
  3. Set name: web-health-probe
  4. Set protocol: HTTP
  5. Set port: 80
  6. Set path: /
  7. Click “OK”

Step 3: Create Load Balancing Rule

  1. Go to SettingsLoad balancing rules
  2. Click “Add”
  3. Set name: web-lb-rule
  4. Set frontend port: 80
  5. Set backend port: 80
  6. Select health probe: web-health-probe
  7. Click “OK”

Verify: Load balancer is configured with all VMs in backend pool.


Part 3: Install Web Server on VMs

Step 1: Connect to First VM

  1. Go to Virtual machines → WebVM-Zone1
  2. Click “Connect” → “RDP”
  3. Download RDP file and connect using azureuser / Password123!

Step 2: Install IIS

  1. Open Server Manager
  2. Click “Add roles and features”
  3. Select “Web Server (IIS)” role
  4. Complete installation
  5. Open browser and verify IIS default page loads

Step 3: Customize Web Page

  1. Navigate to C:\inetpub\wwwroot
  2. Edit iisstart.htm
  3. Add text: “This is WebVM-Zone1”
  4. Save the file

Step 4: Repeat for Other VMs

  1. Connect to WebVM-Zone2 and WebVM-Zone3
  2. Install IIS on both VMs
  3. Customize pages to show “WebVM-Zone2” and “WebVM-Zone3”

Verify: Each VM shows its unique identifier when accessed directly.


Part 4: Test Load Balancer

Step 1: Access Load Balancer IP

  1. Go to Load balancers → avail-lb[unique]
  2. Copy the public IP address
  3. Open browser and navigate to the IP address
  4. Refresh page multiple times

Expected: You should see different VM pages as load balancer distributes traffic.

Step 2: Test Failover

  1. Stop one VM (WebVM-Zone1)
  2. Refresh browser page multiple times
  3. Observe that traffic only goes to remaining two VMs

Step 3: Restart VM and Verify

  1. Start WebVM-Zone1 again
  2. Wait 2-3 minutes for health probe to detect
  3. Refresh browser to see all three VMs responding again

Verify: Load balancer automatically removes failed VMs and adds them back when healthy.


Part 5: Create Availability Set

Step 1: Create Availability Set

  1. Navigate to Availability setsCreate
  2. Set name: web-availability-set
  3. Select resource group: Availability-Lab-RG
  4. Set fault domains: 2
  5. Set update domains: 5
  6. Click “Create”

Step 2: Create VM in Availability Set

  1. Create new VM: AvailSetVM1
  2. Choose availability options: “Availability set”
  3. Select web-availability-set
  4. Use same credentials and settings as before
  5. Create the VM

Step 3: Add Second VM to Set

  1. Create another VM: AvailSetVM2
  2. Select same availability set: web-availability-set
  3. Complete creation

Verify: Both VMs are in the availability set with different fault domains.


Part 6: Monitor Availability

Step 1: Enable VM Insights

  1. Go to Virtual machines → WebVM-Zone1
  2. Click “Insights” under Monitoring
  3. Click “Enable”
  4. Select Log Analytics workspace or create new
  5. Wait for deployment to complete

Step 2: View Availability Metrics

  1. Go to Monitor → Metrics
  2. Select resource: WebVM-Zone1
  3. Add metric: “VM Availability”
  4. Set time range: Last 4 hours

Step 3: Create Simple Alert

  1. Go to Monitor → Alerts
  2. Click “Create alert rule”
  3. Select resource: WebVM-Zone1
  4. Add condition: VM Availability less than 1
  5. Create action group with email notification
  6. Name the alert: “VM Down Alert”
  7. Create the alert

Verify: Alert is created and will notify when VM becomes unavailable.


Troubleshooting Guide

Common Availability Issues

IssueSymptomsPossible CauseSolution
VMs not distributing across zonesAll instances in single zone despite configurationCapacity constraints or SKU limitationsVerify VM size availability in all zones and consider different SKU
Load balancer not detecting failuresTraffic continues to unhealthy instancesHealth probe misconfiguration or endpoint issuesCheck health probe settings and ensure application health endpoint responds
Availability set deployment failuresCannot add VM to existing availability setMixing managed and unmanaged disksEnsure consistent disk types (managed disks recommended)
Zone-redundant services unavailableOptions grayed out during resource creationRegion or service limitationsVerify regional support for zone-redundant services and select supported region
High latency between zonesPoor application performance across zonesCross-zone network latency or configurationOptimize application architecture for zone-aware design and minimize cross-zone traffic

Availability Configuration Checklist

ComponentRequirementStatusNotes
VM placementDistributed across zones or fault domainsEnsures protection against infrastructure failures
Load balancer configurationHealth probes and backend pools configuredEnables automatic traffic distribution and failover
Storage resilienceZone-redundant or geo-redundant storageProtects against data loss during infrastructure failures
Network redundancyMultiple paths and zone-redundant componentsEliminates network single points of failure
Monitoring and alertingAvailability metrics and alerts configuredProvides visibility and proactive issue detection

Best Practices

ScenarioRecommendationBenefit
Mission-critical applicationsDeploy across availability zones with zone-redundant servicesProvides highest level of availability (99.99% SLA)
Cost-sensitive workloadsUse availability sets for basic high availabilityBalances cost and availability for standard applications
Stateful applicationsImplement data replication across zones or regionsEnsures data consistency and availability during failures
Global applicationsDeploy across multiple regions with traffic managerProvides geographic redundancy and disaster recovery
Maintenance planningAlign update domains with maintenance windowsMinimizes business impact during planned maintenance

Optional Advanced Exercises

For users wanting more technical depth, try these exercises:

Advanced Exercise 1: Automated Availability Deployment

Terminal window
# Deploy high availability infrastructure using PowerShell automation
Connect-AzAccount
# Set up variables for multi-zone deployment
$resourceGroup = "Availability-Lab-RG"
$location = "East US"
$vmSize = "Standard_B2s"
$availabilityZones = @("1", "2", "3")
# Create availability zones VMs with automation
foreach ($zone in $availabilityZones) {
$vmName = "AutoVM-Zone$zone"
$subnetName = "Zone${zone}Subnet"
# Create VM configuration
$vmConfig = New-AzVMConfig -VMName $vmName -VMSize $vmSize -Zone $zone
$vmConfig = Set-AzVMOperatingSystem -VM $vmConfig -Windows -ComputerName $vmName -Credential (Get-Credential)
$vmConfig = Set-AzVMSourceImage -VM $vmConfig -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer" -Skus "2019-Datacenter" -Version "latest"
# Create VM with zone placement
New-AzVM -ResourceGroupName $resourceGroup -Location $location -VM $vmConfig -Zone $zone -Verbose
Write-Host "Deployed VM $vmName to Availability Zone $zone"
}
# Configure load balancer backend pools
$loadBalancer = Get-AzLoadBalancer -ResourceGroupName $resourceGroup -Name "avail-lb*"
foreach ($zone in $availabilityZones) {
$backendPoolName = "Zone${zone}Pool"
$vmName = "AutoVM-Zone$zone"
$vm = Get-AzVM -ResourceGroupName $resourceGroup -Name $vmName
$nic = Get-AzNetworkInterface -ResourceId $vm.NetworkProfile.NetworkInterfaces[0].Id
# Add VM to appropriate backend pool
$nic.IpConfigurations[0].LoadBalancerBackendAddressPools = $loadBalancer.BackendAddressPools | Where-Object {$_.Name -eq $backendPoolName}
Set-AzNetworkInterface -NetworkInterface $nic
}
Write-Host "High availability deployment completed successfully"

Advanced Exercise 2: Availability Set Optimization

Terminal window
# Create optimized availability set with proximity placement groups
$resourceGroup = "Availability-Lab-RG"
$location = "East US"
# Create proximity placement group for low latency
$ppg = New-AzProximityPlacementGroup -ResourceGroupName $resourceGroup -Name "web-ppg" -Location $location -ProximityPlacementGroupType "Standard"
# Create optimized availability set
$availSet = New-AzAvailabilitySet -ResourceGroupName $resourceGroup -Name "optimized-availability-set" -Location $location -PlatformFaultDomainCount 3 -PlatformUpdateDomainCount 5 -ProximityPlacementGroupId $ppg.Id -Sku "Aligned"
# Deploy VMs with optimized placement
$vmConfigs = @()
for ($i = 1; $i -le 3; $i++) {
$vmName = "OptimizedVM$i"
$vmConfig = New-AzVMConfig -VMName $vmName -VMSize "Standard_D2s_v3" -AvailabilitySetId $availSet.Id -ProximityPlacementGroupId $ppg.Id
$vmConfig = Set-AzVMOperatingSystem -VM $vmConfig -Windows -ComputerName $vmName -Credential (Get-Credential)
$vmConfig = Set-AzVMSourceImage -VM $vmConfig -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer" -Skus "2019-Datacenter" -Version "latest"
$vmConfigs += $vmConfig
}
# Deploy all VMs concurrently
$jobs = @()
foreach ($config in $vmConfigs) {
$job = Start-Job -ScriptBlock {
param($rg, $loc, $vmConfig)
New-AzVM -ResourceGroupName $rg -Location $loc -VM $vmConfig
} -ArgumentList $resourceGroup, $location, $config
$jobs += $job
}
# Wait for all deployments to complete
$jobs | Wait-Job | Receive-Job
Write-Host "Optimized availability set deployment completed"

Advanced Exercise 3: Availability Monitoring and Alerting

Terminal window
# Set up comprehensive availability monitoring
$resourceGroup = "Availability-Lab-RG"
$workspaceName = "availability-workspace"
# Create Log Analytics workspace for centralized monitoring
$workspace = New-AzOperationalInsightsWorkspace -ResourceGroupName $resourceGroup -Name $workspaceName -Location "East US" -Sku "Standard"
# Enable VM insights for all VMs
$vms = Get-AzVM -ResourceGroupName $resourceGroup
foreach ($vm in $vms) {
# Install monitoring agent
Set-AzVMExtension -ResourceGroupName $resourceGroup -VMName $vm.Name -Name "MicrosoftMonitoringAgent" -Publisher "Microsoft.EnterpriseCloud.Monitoring" -ExtensionType "MicrosoftMonitoringAgent" -TypeHandlerVersion "1.0" -Settings @{"workspaceId" = $workspace.CustomerId} -ProtectedSettings @{"workspaceKey" = (Get-AzOperationalInsightsWorkspaceSharedKeys -ResourceGroupName $resourceGroup -Name $workspaceName).PrimarySharedKey}
}
# Create availability alert rules
$actionGroup = New-AzActionGroup -ResourceGroupName $resourceGroup -Name "AvailabilityAlerts" -ShortName "AvailAlert" -EmailReceiver @{Name="Operations"; EmailAddress="ops@company.com"}
# VM availability alert
$vmAvailabilityAlert = New-AzMetricAlertRuleV2 -ResourceGroupName $resourceGroup -Name "VM-Availability-Alert" -TargetResourceId "/subscriptions/$($(Get-AzContext).Subscription.Id)/resourceGroups/$resourceGroup" -WindowSize "00:05:00" -Frequency "00:01:00" -MetricName "VmAvailabilityMetric" -Operator LessThan -Threshold 0.99 -Severity 2 -ActionGroup $actionGroup
# Load balancer health alert
$lbHealthAlert = New-AzMetricAlertRuleV2 -ResourceGroupName $resourceGroup -Name "LB-Health-Alert" -TargetResourceId (Get-AzLoadBalancer -ResourceGroupName $resourceGroup).Id -WindowSize "00:05:00" -Frequency "00:01:00" -MetricName "VipAvailability" -Operator LessThan -Threshold 0.99 -Severity 1 -ActionGroup $actionGroup
Write-Host "Comprehensive availability monitoring configured successfully"

Key Takeaways

After completing this lab, you should understand:

  • Availability zones provide the highest level of resiliency by distributing resources across physically separate datacenters within a region, achieving 99.99% SLA
  • Availability sets protect against local failures within a single datacenter using fault and update domains, providing 99.95% SLA at lower cost
  • Load balancer configuration is critical for automatic failover and traffic distribution across available instances during failures
  • Health probes and monitoring enable proactive detection of issues and automatic traffic redirection to healthy instances
  • Proper capacity planning ensures adequate resources remain available during zone or domain failures to maintain performance
  • Cost optimization requires balancing availability requirements with infrastructure expenses based on business criticality and SLA targets

Availability Decision Matrix

Availability Strategy Selection

CriteriaSingle VMAvailability SetAvailability ZonesMulti-RegionRecommendation
SLA requirement99.9%99.95%99.99%99.995%+Choose based on business SLA requirements
Cost impactLowestMediumHigherHighestAvailability sets for cost-sensitive workloads
ComplexitySimpleModerateModerateHighStart simple, evolve based on requirements
Regional resilienceNoneNoneHighMaximumZones for regional disasters, multi-region for global

Failure Protection Coverage

Failure TypeSingle VMAvailability SetAvailability ZoneMulti-Region
Hardware failure❌ No protection✅ Protected✅ Protected✅ Protected
Rack failure❌ No protection✅ Protected✅ Protected✅ Protected
Datacenter failure❌ No protection❌ No protection✅ Protected✅ Protected
Regional disaster❌ No protection❌ No protection❌ No protection✅ Protected
Planned maintenance❌ Downtime required✅ Zero downtime✅ Zero downtime✅ Zero downtime

Cost vs Availability Trade-offs

ScenarioOptimization StrategyExpected Outcome
Development/TestingSingle VMs with automated backups70-80% cost savings with acceptable availability for non-production
Standard ProductionAvailability sets with load balancingBalanced cost and availability with 99.95% SLA
Mission-CriticalAvailability zones with zone-redundant servicesPremium availability (99.99% SLA) with 20-30% cost increase
Global EnterpriseMulti-region deployment with traffic managementMaximum availability (99.995%+) with 2-3x cost increase

Additional Resources