Azure Load Balancer

Introduction

The Azure Load Balancer distributes inbound traffic across multiple virtual machines, ensuring high availability and reliability for your services. It operates at the transport layer (Layer 4) and supports both inbound and outbound scenarios.

Key Features

Getting Started

Follow these steps to create a basic load balancer:

# Create a resource group
az group create --name MyResourceGroup --location eastus

# Create a public IP address
az network public-ip create --resource-group MyResourceGroup --name MyPublicIP

# Create a load balancer
az network lb create \
  --resource-group MyResourceGroup \
  --name MyLoadBalancer \
  --frontend-ip-name MyFrontEnd \
  --public-ip-address MyPublicIP

# Add a backend pool
az network lb address-pool create \
  --resource-group MyResourceGroup \
  --lb-name MyLoadBalancer \
  --name MyBackEndPool

# Create a health probe
az network lb probe create \
  --resource-group MyResourceGroup \
  --lb-name MyLoadBalancer \
  --name MyHealthProbe \
  --protocol tcp \
  --port 80

# Create a load balancing rule
az network lb rule create \
  --resource-group MyResourceGroup \
  --lb-name MyLoadBalancer \
  --name MyHTTPRule \
  --protocol tcp \
  --frontend-port 80 \
  --backend-port 80 \
  --frontend-ip-name MyFrontEnd \
  --backend-pool-name MyBackEndPool \
  --probe-name MyHealthProbe

Health Probes

Health probes determine the health of each VM in the backend pool. The load balancer only forwards traffic to healthy instances.

Probe Type Port Interval Unhealthy Threshold
TCP 80 5 sec 2
HTTP 8080 10 sec 3

Monitoring & Metrics

Azure Monitor provides real‑time metrics and logs for your load balancer. Use the portal or Azure CLI to view throughput, dip, and health probe status.