title | titleSuffix | description | services | documentationcenter | author | ms.service | ms.topic | ms.custom | ms.tgt_pltfrm | ms.workload | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Configure Azure Load Balancer distribution mode |
Azure Load Balancer |
In this article, get started configuring the distribution mode for Azure Load Balancer to support source IP affinity. |
load-balancer |
na |
greg-lindsay |
load-balancer |
how-to |
seodec18, devx-track-azurecli, devx-track-azurepowershell |
na |
infrastructure-services |
02/04/2021 |
greglin |
Azure Load Balancer supports two distribution modes for distributing traffic to your applications:
- Hash-based
- Source IP affinity
In this article, you learn how to configure the distribution mode for your Azure Load Balancer.
You can change the configuration of the distribution mode by modifying the load-balancing rule in the portal.
- Sign in to the Azure portal and locate the resource group containing the load balancer you wish to change by clicking on Resource Groups.
- In the load balancer overview screen, select Load-balancing rules under Settings.
- In the load-balancing rules screen, select the load-balancing rule that you wish to change the distribution mode.
- Under the rule, the distribution mode is changed by changing the Session persistence drop-down box.
The following options are available:
- None (hash-based) - Specifies that successive requests from the same client may be handled by any virtual machine.
- Client IP (source IP affinity two-tuple) - Specifies that successive requests from the same client IP address will be handled by the same virtual machine.
- Client IP and protocol (source IP affinity three-tuple) - Specifies that successive requests from the same client IP address and protocol combination will be handled by the same virtual machine.
- Choose the distribution mode and then select Save.
:::image type="content" source="./media/load-balancer-distribution-mode/session-persistence.png" alt-text="Change session persistence on load balancer rule." border="true":::
[!INCLUDE updated-for-az]
Use PowerShell to change the load-balancer distribution settings on an existing load-balancing rule. The following command updates the distribution mode:
$lb = Get-AzLoadBalancer -Name MyLoadBalancer -ResourceGroupName MyResourceGroupLB
$lb.LoadBalancingRules[0].LoadDistribution = 'default'
Set-AzLoadBalancer -LoadBalancer $lb
Set the value of the LoadDistribution
element for the type of load balancing required.
-
Specify SourceIP for two-tuple (source IP and destination IP) load balancing.
-
Specify SourceIPProtocol for three-tuple (source IP, destination IP, and protocol type) load balancing.
-
Specify Default for the default behavior of five-tuple load balancing.
[!INCLUDE azure-cli-prepare-your-environment.md]
Use Azure CLI to change the load-balancer distribution settings on an existing load-balancing rule. The following command updates the distribution mode:
az network lb rule update \
--lb-name myLoadBalancer \
--load-distribution Default \
--name myHTTPRule \
--resource-group myResourceGroupLB
Set the value of --load-distribution
for the type of load balancing required.
-
Specify SourceIP for two-tuple (source IP and destination IP) load balancing.
-
Specify SourceIPProtocol for three-tuple (source IP, destination IP, and protocol type) load balancing.
-
Specify Default for the default behavior of five-tuple load balancing.
For more information on the command used in this article, see az network lb rule update