Microsoft Docs

Azure Load Balancer

Azure Load Balancer is a Layer 4 (TCP/UDP) load balancer that enables you to distribute network traffic across multiple virtual machines or cloud services. It provides high availability and improves application responsiveness by routing traffic to healthy instances. Azure Load Balancer is a fully managed service, offering scalability, resilience, and low latency.

Key Features and Benefits

How Azure Load Balancer Works

Azure Load Balancer operates in front of your virtual machines or cloud services. When a client sends a request to the load balancer's public or internal IP address, the load balancer uses configured load balancing rules to decide which backend instance should receive the request. Health probes are crucial; they periodically send requests to backend instances. If an instance fails to respond, it's marked as unhealthy, and the load balancer stops sending traffic to it until it becomes healthy again.

Common Use Cases

Configuring Azure Load Balancer

Configuration typically involves the following steps:

  1. Create a Load Balancer: Choose between Standard or Basic SKU, and public or internal type.
  2. Configure a Backend Pool: Associate the load balancer with the virtual machines or scale sets that will receive traffic.
  3. Define Health Probes: Specify the protocol, port, and interval for checking the health of backend instances.
  4. Create Load Balancing Rules: Map frontend IP addresses and ports to backend pools and ports.
  5. Configure NAT Rules (Optional): For inbound direct server return scenarios.

Important Note:

The Standard SKU of Azure Load Balancer offers more advanced features, including Availability Zones support, better diagnostics, and session persistence. The Basic SKU is suitable for simpler scenarios and cost-effectiveness.

Example Configuration Snippet (ARM Template)

Here's a simplified example of an ARM template snippet for creating a Standard Load Balancer:


{
  "type": "Microsoft.Network/loadBalancers",
  "apiVersion": "2023-05-01",
  "name": "myLoadBalancer",
  "location": "[resourceGroup().location]",
  "sku": {
    "name": "Standard"
  },
  "properties": {
    "frontendIPConfigurations": [
      {
        "name": "myFrontendIP",
        "properties": {
          "publicIPAddress": {
            "id": "[resourceId('Microsoft.Network/publicIPAddresses', 'myPublicIP')]"
          }
        }
      }
    ],
    "backendAddressPools": [
      {
        "name": "myBackendPool"
      }
    ],
    "loadBalancingRules": [
      {
        "name": "myHTTPRule",
        "properties": {
          "frontendIPConfiguration": {
            "id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', 'myLoadBalancer', 'myFrontendIP')]"
          },
          "backendAddressPool": {
            "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', 'myLoadBalancer', 'myBackendPool')]"
          },
          "protocol": "Tcp",
          "frontendPort": 80,
          "backendPort": 80,
          "enableFloatingIP": false,
          "idleTimeoutInMinutes": 4,
          "disableOutboundSnat": false
        }
      }
    ],
    "healthProbes": [
      {
        "name": "myHealthProbe",
        "properties": {
          "protocol": "Tcp",
          "port": 80,
          "intervalInSeconds": 5,
          "numberOfProbes": 2
        }
      }
    ]
  }
}
            

Further Reading