Load Balancer

Overview

The Load Balancer builder (loadBalancer) creates load balancers that can distribute load amongst healthy services in a backend pool on public or private networks.

  • Load balancers (Microsoft.Network/loadBalancers)
  • Load balancer frontend IP configurations (Microsoft.Network/loadBalancers/frontendIPConfigurations)
  • Load balancer backend address pools (Microsoft.Network/loadBalancers/backendAddressPools)
  • Load balancer health probes (Microsoft.Network/loadBalancers/probes)

Builder Keywords

Applies ToKeywordPurpose
loadBalancernameSpecifies the name of the load balancer
loadBalancerskuSpecifies the SKU of the load balancer - default is ‘Basic’.
loadBalancertierSpecifies the tier of the load balancer - default is ‘Regional’.
loadBalanceradd_frontendsAdds frontend IP configurations as defined by the frontend builder.
loadBalanceradd_backend_poolsAdds backend address pool configurations as defined by the backendAddressPool builder.
loadBalanceradd_rulesAdds load balancing rules as defined by the loadBalancingRule builder.
loadBalanceradd_probesAdds probes for the address pool as defined by the loadBalancerProbe builder.
loadBalanceradd_dependenciesAdds the resource ID’s of additional dependencies that must be provisioned before the load balancer.
frontendnameName of the frontend IP configuration.
frontendip_v6Generates an IPv6 IP address for the frontend.
frontendprivate_ip_allocation_methodSpecifies how the private IP is assigned on an internal load balancer.
frontendpublic_ipSpecifies the name of a public IP to generate. It will be generated with the same SKU as the load balancer.
frontendlink_to_public_ipThe name of an existing public IP to link to.
backendAddressPoolnameThe name of the backend address pool.
backendAddressPoolload_balancerThe name of a load balancer these should be added to (used when adding to a pool for an existing load balancer).
backendAddressPoolvnetSpecifies a virtual network in the same deployment where the backend services are connected.
backendAddressPoollink_to_vnetSpecifies an existing virtual network where the backend services are connected.
backendAddressPoolsubnetSpecifies a subnet in the same deployment where the backend services are connected.
backendAddressPoollink_to_subnetSpecifies an existing subnet where the backend services are connected.
backendAddressPooladd_ip_addressesAdds IP addresses to the backend pool.
loadBalancerProbenameThe name of the load balancer probe.
loadBalancerProbeprotocolThe protocol to use for the probe - default is TCP.
loadBalancerProbeportThe port to probe on the backend service.
loadBalancerProberequest_pathFor HTTP(S) probes, the request path that returns a 200 when healthy.
loadBalancerProbeintervalThe interval between 4 and 30 seconds to probe the health of the services in the pool.
loadBalancerProbenumber_of_probesThe number of probe attempts before considering the service unhealthy.
loadBalancingRulenameThe name of the load balancing rule.
loadBalancingRulefrontend_ip_configThe name of the frontend IP configuration to which this rule applies.
loadBalancingRulebackend_address_poolThe name of the backend address pool to which this rule applies.
loadBalancingRuleprobeThe name of the probe to use to check the health of services in the backend pool.
loadBalancingRulefrontend_portThe port on the frontend to forward to a backend service.
loadBalancingRulebackend_portThe target port on the backend service.
loadBalancingRuleprotocolThe protocol to forward, defaults to ‘All’.
loadBalancingRuleidle_timeout_minutesThe time in minutes before a TCP connection is considered idle and disconnected.
loadBalancingRuleload_distribution_policyThe load distribution policy - ‘Default’ where a request can go to any backend, ‘SourceIP’ which is mapped on client IP, or ‘SourceIPProtocol’ which is mapped on client IP and protocol.
loadBalancingRuleenable_tcp_resetAfter an idle timeout, the TCP connection is reset - defaults to ‘disabled’.
loadBalancingRuleenable_outbound_snatAllows backend services to use this load balancer for outbound connections - defaults to ‘disabled’.

Example

open Farmer
open Farmer.Builders
open Farmer.LoadBalancer

arm {
    add_resources [
        vnet {
            name "my-vnet"
            add_address_spaces [ "10.0.1.0/24" ]
            add_subnets [
                subnet {
                    name "my-subnet"
                    prefix "10.0.1.0/24"
                    add_delegations [
                        SubnetDelegationService.ContainerGroups
                    ]
                }
            ]
        }
        loadBalancer {
            name "lb"
            sku Sku.Standard
            add_frontends [
                frontend {
                    name "lb-frontend"
                    public_ip "lb-pip"
                }
            ]
            add_backend_pools [
                backendAddressPool {
                    name "lb-backend"
                    vnet "my-vnet"
                    subnet "my-subnet"
                    add_ip_addresses [
                        "10.0.1.4"
                        "10.0.1.5"
                    ]
                }
            ]
            add_probes [
                loadBalancerProbe {
                    name "httpGet"
                    protocol LoadBalancerProbeProtocol.HTTP
                    port 8080
                    request_path "/"
                }
            ]
            add_rules [
                loadBalancingRule {
                    name "rule1"
                    frontend_ip_config "lb-frontend"
                    backend_address_pool "lb-backend"
                    frontend_port 80
                    backend_port 8080
                    protocol TransmissionProtocol.TCP
                    probe "httpGet"
                }
            ]
        }
    ]
}