๐ง Appropriate Use Cases for Azure Load Balancer
graph LR
A[Use Cases] --> B[Web Applications]
A --> C[Database Clusters]
A --> D[Microservices]
A --> E[Legacy Applications]
B --> B1[Multi-tier Apps]
B --> B2[E-commerce Sites]
B --> B3[Content Delivery]
C --> C1[SQL Server AlwaysOn]
C --> C2[MySQL Clusters]
C --> C3[NoSQL Databases]
D --> D1[Container Workloads]
D --> D2[API Gateways]
D --> D3[Service Mesh]
E --> E1[Mainframe Integration]
E --> E2[Custom TCP/UDP Apps]
E --> E3[Gaming Servers]
style A fill:#e3f2fd
style B fill:#e8f5e8
style C fill:#fff3e0
style D fill:#f3e5f5
style E fill:#fce4ec
๐ Web Application Load Balancing
Scenario: Multi-tier web application with frontend web servers
Configuration: Public Load Balancer with HTTP/HTTPS health probes
Benefits: High availability, automatic scaling, SSL termination
๐๏ธ Database High Availability
Scenario: SQL Server AlwaysOn Availability Groups
Configuration: Internal Load Balancer with TCP health probes
Benefits: Transparent failover, connection persistence, zone redundancy
๐ Microservices Architecture
Scenario: Container-based microservices with dynamic scaling
Configuration: Multiple backend pools with custom health probes
Benefits: Service discovery integration, blue-green deployments
๐ฎ Gaming and Real-time Applications
Scenario: UDP-based gaming servers or real-time communication
Configuration: UDP load balancing with TCP health probes
Benefits: Low latency, session affinity, global load balancing
๐ก Best Practice: Choose Internal Load Balancer for backend services and Public Load Balancer for internet-facing applications. Consider Application Gateway for Layer 7 features like URL routing and WAF.
๐ Choose Azure Load Balancer SKU and Tier
graph TD
A[SKU Selection Decision Tree] --> B{Application Scope}
B -->|Single Region| C{Performance Requirements}
B -->|Multi Region| D[Standard SKU + Global Load Balancer]
C -->|Basic Needs| E{Budget Constraints}
C -->|High Performance| F[Standard SKU]
E -->|Cost Sensitive| G[Basic SKU]
E -->|Production Ready| H[Standard SKU]
F --> I[Standard Features]
G --> J[Basic Features]
H --> I
D --> K[Global Features]
I --> I1[SLA 99.99%]
I --> I2[Availability Zones]
I --> I3[Outbound Rules]
I --> I4[Multiple Frontend IPs]
J --> J1[No SLA]
J --> J2[Single AZ]
J --> J3[Default SNAT]
J --> J4[Single Frontend IP]
K --> K1[Cross-region Load Balancing]
K --> K2[Global Anycast IP]
K --> K3[Health-based Routing]
style A fill:#e1f5fe
style G fill:#c8e6c9
style F fill:#bbdefb
style D fill:#d1c4e9
Basic SKU
๐ฐ Cost-Effective Choice
- โ
Free tier available
- โ
Simple load balancing
- โ
Basic health probes
- โ No SLA guarantee
- โ Single availability zone
- โ Limited to 300 instances
- โ No metrics/diagnostics
Best for: Development, testing, proof-of-concept
Standard SKU
๐ Production Ready
- โ
99.99% SLA
- โ
Availability zone support
- โ
Up to 1000 instances
- โ
Advanced health probes
- โ
Outbound rules control
- โ
Multiple frontend IPs
- โ
Rich metrics & diagnostics
Best for: Production workloads, mission-critical apps
Gateway Load Balancer
๐ Network Appliance Integration
- โ
Transparent network appliance insertion
- โ
Chaining with 3rd party NVAs
- โ
GENEVE encapsulation
- โ
High performance (up to 50 Gbps)
- ๐ Maintains flow stickiness
- ๐ Scale out/in NVAs
Best for: Security appliances, inspection, filtering
โ ๏ธ Important: Basic and Standard SKU resources cannot be mixed. Once deployed, you cannot change SKU types - you must recreate the load balancer.
Feature |
Basic |
Standard |
Gateway |
Backend pool size |
Up to 300 |
Up to 1000 |
Up to 1000 |
Availability zones |
โ |
โ
|
โ
|
SLA |
None |
99.99% |
99.99% |
Health probes |
HTTP, TCP |
HTTP, HTTPS, TCP |
HTTP, HTTPS, TCP |
Outbound rules |
โ |
โ
|
โ
|
Multiple frontends |
โ |
โ
|
โ
|
Diagnostics |
โ |
โ
|
โ
|
๐ป Azure CLI Configuration
graph TB
RG[Resource Group
rg-loadbalancer-prod] --> VNET[Virtual Network
vnet-prod
10.0.0.0/16]
VNET --> SUBNET1[Web Subnet
subnet-web
10.0.1.0/24]
VNET --> SUBNET2[DB Subnet
subnet-db
10.0.2.0/24]
PIP[Public IP
pip-lb-prod
Standard SKU
Zone Redundant] --> LB[Public Load Balancer
lb-web-prod
Standard SKU]
LB --> FE[Frontend IP Config
frontend-web
Public IP Association]
LB --> BE[Backend Pool
backend-web
VM Collection]
LB --> PROBE[Health Probe
health-probe-http
HTTP:80/health]
LB --> RULE[Load Balancing Rule
rule-http
Port 80โ80]
LB --> OUT[Outbound Rule
outbound-rule
SNAT Configuration]
NSG[Network Security Group
nsg-web-servers] --> NSGRULE1[Allow HTTP:80]
NSG --> NSGRULE2[Allow HTTPS:443]
AVSET[Availability Set
avset-web
2 Fault Domains]
VM1[Virtual Machine
vm-web-01
Zone 1] --> NIC1[Network Interface
vm-web-01VMNic]
VM2[Virtual Machine
vm-web-02
Zone 2] --> NIC2[Network Interface
vm-web-02VMNic]
NIC1 --> SUBNET1
NIC2 --> SUBNET1
NIC1 --> NSG
NIC2 --> NSG
NIC1 --> BE
NIC2 --> BE
PROBE --> RULE
FE --> RULE
BE --> RULE
%% Internal Load Balancer Branch
ILB[Internal Load Balancer
lb-db-internal
Standard SKU] --> FE_INT[Frontend IP Config
frontend-db
10.0.2.10]
ILB --> BE_INT[Backend Pool
backend-db
Database VMs]
ILB --> PROBE_INT[Health Probe
health-probe-sql
TCP:1433]
ILB --> RULE_INT[Load Balancing Rule
rule-sql
Port 1433โ1433
Floating IP Enabled]
FE_INT --> SUBNET2
PROBE_INT --> RULE_INT
FE_INT --> RULE_INT
BE_INT --> RULE_INT
%% Styling
style RG fill:#e8f5e8
style VNET fill:#e1f5fe
style LB fill:#bbdefb
style ILB fill:#c8e6c9
style VM1 fill:#fff3e0
style VM2 fill:#fff3e0
style NSG fill:#fce4ec
style PIP fill:#f3e5f5
Resource Relationship Overview
๐ Key Relationships:
- Public IP โ Load Balancer: Provides internet-facing endpoint
- Frontend IP โ Load Balancing Rule: Defines where traffic enters
- Backend Pool โ Load Balancing Rule: Defines where traffic is distributed
- Health Probe โ Load Balancing Rule: Ensures traffic only goes to healthy instances
- Network Interface โ Backend Pool: Associates VMs with load balancer
- NSG โ Network Interface: Controls traffic flow to VMs
Standard Load Balancer Setup
az group create \
--name rg-loadbalancer-prod \
--location eastus2
az network vnet create \
--resource-group rg-loadbalancer-prod \
--name vnet-prod \
--address-prefix 10.0.0.0/16 \
--subnet-name subnet-web \
--subnet-prefix 10.0.1.0/24
az network public-ip create \
--resource-group rg-loadbalancer-prod \
--name pip-lb-prod \
--sku Standard \
--allocation-method Static \
--zone 1 2 3
az network lb create \
--resource-group rg-loadbalancer-prod \
--name lb-web-prod \
--sku Standard \
--public-ip-address pip-lb-prod \
--frontend-ip-name frontend-web \
--backend-pool-name backend-web
az network lb probe create \
--resource-group rg-loadbalancer-prod \
--lb-name lb-web-prod \
--name health-probe-http \
--protocol Http \
--port 80 \
--path /health \
--interval 15 \
--threshold 2
az network lb rule create \
--resource-group rg-loadbalancer-prod \
--lb-name lb-web-prod \
--name rule-http \
--protocol Tcp \
--frontend-port 80 \
--backend-port 80 \
--frontend-ip-name frontend-web \
--backend-pool-name backend-web \
--probe-name health-probe-http \
--idle-timeout 15 \
--enable-tcp-reset true
az network nsg create \
--resource-group rg-loadbalancer-prod \
--name nsg-web-servers
az network nsg rule create \
--resource-group rg-loadbalancer-prod \
--nsg-name nsg-web-servers \
--name AllowHTTP \
--protocol Tcp \
--priority 1000 \
--destination-port-range 80 \
--access Allow
az network nsg rule create \
--resource-group rg-loadbalancer-prod \
--nsg-name nsg-web-servers \
--name AllowHTTPS \
--protocol Tcp \
--priority 1010 \
--destination-port-range 443 \
--access Allow
az vm availability-set create \
--resource-group rg-loadbalancer-prod \
--name avset-web \
--platform-fault-domain-count 2 \
--platform-update-domain-count 5
for i in {1..2}; do
az vm create \
--resource-group rg-loadbalancer-prod \
--name vm-web-0$i \
--image Ubuntu2204 \
--size Standard_B2s \
--vnet-name vnet-prod \
--subnet subnet-web \
--nsg nsg-web-servers \
--zone $i \
--admin-username azureuser \
--generate-ssh-keys \
--custom-data cloud-init.txt
done
for i in {1..2}; do
az network nic ip-config address-pool add \
--resource-group rg-loadbalancer-prod \
--nic-name vm-web-0${i}VMNic \
--ip-config-name ipconfig1 \
--lb-name lb-web-prod \
--address-pool backend-web
done
az network lb outbound-rule create \
--resource-group rg-loadbalancer-prod \
--lb-name lb-web-prod \
--name outbound-rule \
--frontend-ip-configs frontend-web \
--protocol All \
--backend-pool backend-web \
--allocated-outbound-ports 10000
Internal Load Balancer for Backend Services
az network lb create \
--resource-group rg-loadbalancer-prod \
--name lb-db-internal \
--sku Standard \
--vnet-name vnet-prod \
--subnet subnet-db \
--frontend-ip-name frontend-db \
--backend-pool-name backend-db \
--private-ip-address 10.0.2.10
az network lb probe create \
--resource-group rg-loadbalancer-prod \
--lb-name lb-db-internal \
--name health-probe-sql \
--protocol Tcp \
--port 1433 \
--interval 5 \
--threshold 2
az network lb rule create \
--resource-group rg-loadbalancer-prod \
--lb-name lb-db-internal \
--name rule-sql \
--protocol Tcp \
--frontend-port 1433 \
--backend-port 1433 \
--frontend-ip-name frontend-db \
--backend-pool-name backend-db \
--probe-name health-probe-sql \
--load-distribution SourceIP \
--enable-floating-ip true
๐ Configuration Order and Dependencies
graph TD
A[1. Create Resource Group
az group create] --> B[2. Create Virtual Network
az network vnet create]
B --> C[3. Create Subnets
Included in vnet create]
C --> D{4. Load Balancer Type}
D -->|Public| E[5a. Create Public IP
az network public-ip create
Standard SKU + Zones]
D -->|Internal| F[5b. Skip Public IP
Use private IP instead]
E --> G[6. Create Load Balancer
az network lb create]
F --> G
G --> H[7. Frontend IP Config
Created with LB
or az network lb frontend-ip create]
H --> I[8. Create Backend Pool
Created with LB
or az network lb address-pool create]
I --> J[9. Create Health Probes
az network lb probe create]
J --> K[10. Create LB Rules
az network lb rule create
Links: Frontend + Backend + Probe]
%% Parallel Infrastructure Tasks
L[Parallel: Create NSG
az network nsg create] --> M[Add NSG Rules
az network nsg rule create]
M --> N[Create Availability Set
az vm availability-set create]
N --> O[Create Virtual Machines
az vm create
Associate with NSG + Subnet]
K --> P[11. Add VMs to Backend Pool
az network nic ip-config address-pool add]
O --> P
P --> Q[12. Create Outbound Rules
az network lb outbound-rule create
Control SNAT behavior]
Q --> R[13. Configure Monitoring
az monitor diagnostic-settings create]
R --> S[14. Test & Validate
Verify health probes + connectivity]
%% Critical Dependencies
T[Dependencies] --> T1[VNet must exist before LB]
T --> T2[Probes before LB Rules]
T --> T3[Backend Pool before adding VMs]
T --> T4[NSG before VM creation]
style A fill:#e8f5e8
style D fill:#fff3e0
style G fill:#bbdefb
style K fill:#f3e5f5
style P fill:#fce4ec
style S fill:#e1f5fe
style T fill:#ffebee
sequenceDiagram
participant Admin as Administrator
participant CLI as Azure CLI
participant ARM as Azure Resource Manager
participant LB as Load Balancer
participant VM as Virtual Machine
Admin->>CLI: az group create
CLI->>ARM: Create resource group
ARM-->>CLI: Resource group created
Admin->>CLI: az network vnet create
CLI->>ARM: Create virtual network + subnet
ARM-->>CLI: Network infrastructure ready
Admin->>CLI: az network public-ip create
CLI->>ARM: Allocate public IP (Standard SKU)
ARM-->>CLI: Public IP allocated
Admin->>CLI: az network lb create
CLI->>ARM: Create load balancer with frontend/backend
ARM->>LB: Initialize load balancer
LB-->>ARM: Load balancer ready
ARM-->>CLI: Load balancer created
Admin->>CLI: az network lb probe create
CLI->>ARM: Configure health probe
ARM->>LB: Add health monitoring
LB-->>ARM: Probe configured
Admin->>CLI: az network lb rule create
CLI->>ARM: Create load balancing rule
ARM->>LB: Link frontendโbackend with probe
LB-->>ARM: Rule active
Admin->>CLI: az vm create (multiple)
CLI->>ARM: Deploy virtual machines
ARM->>VM: Initialize VMs with NICs
VM-->>ARM: VMs ready
Admin->>CLI: az network nic ip-config address-pool add
CLI->>ARM: Associate VMs with backend pool
ARM->>LB: Register backend targets
LB->>VM: Start health probing
VM-->>LB: Health status response
LB-->>ARM: Backend pool updated
Admin->>CLI: Test connectivity
CLI->>LB: Send test traffic
LB->>VM: Distribute traffic based on rules
VM-->>LB: Application response
LB-->>CLI: Traffic flow successful
๐ง Configuration Best Practices:
- Pre-planning: Design your network topology and IP addressing scheme first
- Security First: Create NSGs and rules before deploying VMs
- Health Probes: Configure appropriate probe intervals and thresholds
- Testing: Validate each component before moving to the next step
- Monitoring: Enable diagnostics and metrics from the beginning
โ ๏ธ Critical Order Dependencies:
- Virtual Network must exist before Load Balancer creation
- Health Probes must be created before Load Balancing Rules
- Backend Pool must exist before adding VMs to it
- NSG rules should be configured before VM deployment
๐ Monitoring and Troubleshooting
az monitor diagnostic-settings create \
--resource-group rg-loadbalancer-prod \
--name lb-diagnostics \
--resource lb-web-prod \
--resource-type Microsoft.Network/loadBalancers \
--logs '[{"category":"LoadBalancerAlertEvent","enabled":true},{"category":"LoadBalancerProbeHealthStatus","enabled":true}]' \
--metrics '[{"category":"AllMetrics","enabled":true}]' \
--workspace /subscriptions/{subscription-id}/resourceGroups/rg-monitoring/providers/Microsoft.OperationalInsights/workspaces/law-monitoring
az network lb show \
--resource-group rg-loadbalancer-prod \
--name lb-web-prod \
--query "provisioningState"
az network lb probe show \
--resource-group rg-loadbalancer-prod \
--lb-name lb-web-prod \
--name health-probe-http
az network lb list-mapping \
--resource-group rg-loadbalancer-prod \
--name lb-web-prod