Microsoft Docs

Testing Your Azure Load Balancer Configuration

This tutorial walks you through the steps to verify that your Azure Load Balancer is correctly distributing traffic, handling health probes, and responding to failover scenarios.

Overview
Setup
Test Scripts
FAQ

What You’ll Learn

Load Balancer Architecture

Prerequisites

Step 1 – Verify Health Probes

# Azure CLI
az network lb probe show \
  --resource-group MyResourceGroup \
  --lb-name MyLoadBalancer \
  --name MyHealthProbe
Next: Test Distribution

PowerShell Test Script

# Test Load Balancer distribution
$lbIP = "20.30.40.50"
$iterations = 20

for ($i=1; $i -le $iterations; $i++) {
    $response = Invoke-WebRequest -Uri "http://$lbIP/api/instance" -UseBasicParsing
    Write-Host "$i: $($response.Content)"
    Start-Sleep -Milliseconds 300
}

This script repeatedly calls an endpoint on each backend VM. Ensure the endpoint returns the VM name or ID.

Common Issues

Health probe always unhealthy
Check that the probe port and protocol match the service listening on the VM. Verify NSG rules allow probe traffic.
All requests go to a single VM
Confirm that the backend address pool contains multiple VM NICs and that the load balancing rule uses the correct backend pool.