Skip to content

Commit 7542e24

Browse files
authored
Merge pull request #90102 from ShannonLeavitt/configure-load-balancer-outbound-powershell
edit pass: configure-load-balancer-outbound-powershell
2 parents eab7123 + c30bfe8 commit 7542e24

File tree

1 file changed

+60
-47
lines changed

1 file changed

+60
-47
lines changed
Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Configure load balancing and outbound rules using Azure PowerShell
2+
title: Configure load balancing and outbound rules by using Azure PowerShell
33
titlesuffix: Azure Load Balancer
4-
description: This article shows how to configure load balancing and outbound rules in a Standard Load Balancer using the Azure PowerShell.
4+
description: This article shows how to configure load balancing and outbound rules in Standard Load Balancer by using Azure PowerShell.
55
services: load-balancer
66
author: asudbring
77
ms.service: load-balancer
@@ -10,139 +10,152 @@ ms.date: 09/24/2019
1010
ms.author: allensu
1111

1212
---
13-
# Configure load balancing and outbound rules in Standard load balancer using Azure PowerShell
13+
# Configure load balancing and outbound rules in Standard Load Balancer by using Azure PowerShell
1414

15-
This article shows you how to configure outbound rules in Standard load balancer using Azure PowerShell.
15+
This article shows you how to configure outbound rules in Standard Load Balancer by using Azure PowerShell.
1616

17-
When you are done, the load balancer resource contains two frontends and rules associated with them: one for inbound and another for outbound. Each frontend has a reference to a public IP address and this scenario uses a different public IP address for inbound versus outbound. The load balancing rule provides only inbound load balancing and the outbound rule controls the outbound NAT provided for the VM. This article uses two separate backend pools, one for inbound and one for outbound, to illustrate capability and allow for flexibility for this scenario.
17+
When you finish this article's scenario, the load balancer resource contains two front ends and their associated rules. You have one front end for inbound traffic and another front end for outbound traffic.
18+
19+
Each front end references a public IP address. In this scenario, the public IP address for inbound traffic is different from the address for outbound traffic. The load-balancing rule provides only inbound load balancing. The outbound rule controls the outbound network address translation (NAT) for the VM.
20+
21+
The scenario uses two back-end pools: one for inbound traffic and one for outbound traffic. These pools illustrate capability and provide flexibility for the scenario.
1822

1923
[!INCLUDE [cloud-shell-try-it.md](../../includes/cloud-shell-try-it.md)]
2024

2125
[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)]
2226

23-
## Connect to Azure account
24-
Sign in to your Azure subscription with the [Connect-AzAccount](https://docs.microsoft.com/powershell/module/az.accounts/connect-azaccount?view=azps-2.5.0) command and follow the on-screen directions:
27+
## Connect to your Azure account
28+
Sign in to your Azure subscription by using the [Connect-AzAccount](https://docs.microsoft.com/powershell/module/az.accounts/connect-azaccount?view=azps-2.5.0) command. Then follow the on-screen directions.
2529

2630
```azurepowershell-interactive
2731
Connect-AzAccount
2832
```
29-
## Create resource group
33+
## Create a resource group
3034

31-
Create a resource group with [New-AzResourceGroup](https://docs.microsoft.com/powershell/module/az.resources/new-azresourcegroup?view=azps-2.6.0). An Azure resource group is a logical container into which Azure resources are deployed and managed.
35+
Create a resource group by using [New-AzResourceGroup](https://docs.microsoft.com/powershell/module/az.resources/new-azresourcegroup?view=azps-2.6.0). An Azure resource group is a logical container into which Azure resources are deployed. The resources are then managed from the group.
3236

3337
The following example creates a resource group named *myresourcegroupoutbound* in the *eastus2* location:
3438

3539
```azurepowershell-interactive
3640
New-AzResourceGroup -Name myresourcegroupoutbound -Location eastus
3741
```
38-
## Create virtual network
39-
Create a virtual network named *myvnetoutbound* with a subnet named *mysubnetoutbound* in the *myresourcegroupoutbound* using [New-AzVirtualNetwork](https://docs.microsoft.com/powershell/module/az.network/new-azvirtualnetwork?view=azps-2.6.0) and [New-AzVirtualNetworkSubnetConfig](https://docs.microsoft.com/powershell/module/az.network/new-azvirtualnetworksubnetconfig?view=azps-2.6.0):
42+
## Create a virtual network
43+
Create a virtual network named *myvnetoutbound*. Name its subnet *mysubnetoutbound*. Place it in *myresourcegroupoutbound* by using [New-AzVirtualNetwork](https://docs.microsoft.com/powershell/module/az.network/new-azvirtualnetwork?view=azps-2.6.0) and [New-AzVirtualNetworkSubnetConfig](https://docs.microsoft.com/powershell/module/az.network/new-azvirtualnetworksubnetconfig?view=azps-2.6.0).
4044

4145
```azurepowershell-interactive
4246
$subnet = New-AzVirtualNetworkSubnetConfig -Name mysubnetoutbound -AddressPrefix "192.168.0.0/24"
4347
4448
New-AzVirtualNetwork -Name myvnetoutbound -ResourceGroupName myresourcegroupoutbound -Location eastus -AddressPrefix "192.168.0.0/16" -Subnet $subnet
4549
```
4650

47-
## Create inbound public IP address
51+
## Create an inbound public IP address
52+
53+
To access your web app on the internet, you need a public IP address for the load balancer. Standard Load Balancer supports only standard public IP addresses.
4854

49-
To access your web app on the Internet, you need a public IP address for the load balancer. A Standard load balancer only supports Standard public IP addresses. Use [New-AzPublicIpAddress](https://docs.microsoft.com/powershell/module/az.network/new-azpublicipaddress?view=azps-2.6.0) to create a Standard Public IP address named *mypublicipinbound* in *myresourcegroupoutbound*.
55+
Use [New-AzPublicIpAddress](https://docs.microsoft.com/powershell/module/az.network/new-azpublicipaddress?view=azps-2.6.0) to create a standard public IP address named *mypublicipinbound* in *myresourcegroupoutbound*.
5056

5157
```azurepowershell-interactive
5258
$pubIPin = New-AzPublicIpAddress -ResourceGroupName myresourcegroupoutbound -Name mypublicipinbound -AllocationMethod Static -Sku Standard -Location eastus
5359
```
5460

55-
## Create outbound public IP address
61+
## Create an outbound public IP address
5662

57-
Create a Standard IP address for load balancer's frontend outbound configuration using [New-AzPublicIpAddress](https://docs.microsoft.com/powershell/module/az.network/new-azpublicipaddress?view=azps-2.6.0).
63+
Create a standard IP address for the load balancer's front-end outbound configuration by using [New-AzPublicIpAddress](https://docs.microsoft.com/powershell/module/az.network/new-azpublicipaddress?view=azps-2.6.0).
5864

5965
```azurepowershell-interactive
6066
$pubIPout = New-AzPublicIpAddress -ResourceGroupName myresourcegroupoutbound -Name mypublicipoutbound -AllocationMethod Static -Sku Standard -Location eastus
6167
```
6268

63-
## Create Azure load balancer
69+
## Create an Azure load balancer
6470

65-
This section details how you can create and configure the following components of the load balancer:
66-
- A frontend IP that receives the incoming network traffic on the load balancer.
67-
- A backend pool where the frontend IP sends the load balanced network traffic.
68-
- A backend pool for outbound connectivity.
69-
- A health probe that determines health of the backend VM instances.
70-
- A load balancer inbound rule that defines how traffic is distributed to the VMs.
71-
- A load balancer outbound rule that defines how traffic is distributed from the VMs.
71+
This section explains how to create and configure the following components of the load balancer:
72+
- A front-end IP that receives the incoming network traffic on the load balancer
73+
- A back-end pool where the front-end IP sends the load-balanced network traffic
74+
- A back-end pool for outbound connectivity
75+
- A health probe that determines the health of the back-end VM instances
76+
- A load-balancer inbound rule that defines how traffic is distributed to the VMs
77+
- A load-balancer outbound rule that defines how traffic is distributed from the VMs
7278

73-
### Create inbound frontend IP
74-
Create the outbound frontend IP configuration for the load balancer with [New-AzLoadBalancerFrontendIpConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerfrontendipconfig?view=azps-2.6.0) that includes an inbound frontend IP configuration named *myfrontendinbound* that is associated to the public IP address *mypublicipinbound*
79+
### Create an inbound front-end IP
80+
Create the inbound front-end IP configuration for the load balancer by using [New-AzLoadBalancerFrontendIpConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerfrontendipconfig?view=azps-2.6.0). The load balancer should include an inbound front-end IP configuration named *myfrontendinbound*. Associate this configuration with the public IP address *mypublicipinbound*.
7581

7682
```azurepowershell-interactive
7783
$frontendIPin = New-AzLoadBalancerFrontendIPConfig -Name "myfrontendinbound" -PublicIpAddress $pubIPin
7884
```
79-
### Create outbound frontend IP
80-
Create the outbound frontend IP configuration for the load balancer with [New-AzLoadBalancerFrontendIpConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerfrontendipconfig?view=azps-2.6.0) that includes an outbound frontend IP configuration named *myfrontendoutbound* that is associated to the public IP address *mypublicipoutbound*:
85+
### Create an outbound front-end IP
86+
Create the outbound front-end IP configuration for the load balancer by using [New-AzLoadBalancerFrontendIpConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerfrontendipconfig?view=azps-2.6.0). This load balancer should include an outbound front-end IP configuration named *myfrontendoutbound*. Associate this configuration with the public IP address *mypublicipoutbound*.
8187

8288
```azurepowershell-interactive
8389
$frontendIPout = New-AzLoadBalancerFrontendIPConfig -Name "myfrontendoutbound" -PublicIpAddress $pubIPout
8490
```
85-
### Create inbound backend pool
86-
Create the backend inbound pool for the load balancer with [New-AzLoadBalancerBackendAddressPoolConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerbackendaddresspoolconfig?view=azps-2.6.0) named *bepoolinbound*:
91+
### Create an inbound back-end pool
92+
Create the back-end inbound pool for the load balancer by using [New-AzLoadBalancerBackendAddressPoolConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerbackendaddresspoolconfig?view=azps-2.6.0). Name the pool *bepoolinbound*.
8793

8894
```azurepowershell-interactive
8995
$bepoolin = New-AzLoadBalancerBackendAddressPoolConfig -Name bepoolinbound
9096
```
9197

92-
### Create outbound backend pool
93-
Create an additional backend address pool to define outbound connectivity for a pool of VMs with [New-AzLoadBalancerBackendAddressPoolConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerbackendaddresspoolconfig?view=azps-2.6.0) named *bepooloutbound*. Creating a separate outbound pool provides maximum flexibility, but you can omit this step and only use the inbound *bepoolinbound* as well. :
98+
### Create an outbound back-end pool
99+
Use the following command to create another back-end address pool to define outbound connectivity for a pool of VMs by using [New-AzLoadBalancerBackendAddressPoolConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerbackendaddresspoolconfig?view=azps-2.6.0). Name this pool *bepooloutbound*.
100+
101+
By creating a separate outbound pool, you provide maximum flexibility. But you can omit this step and use only the inbound *bepoolinbound* if you prefer.
94102

95103
```azurepowershell-interactive
96104
$bepoolout = New-AzLoadBalancerBackendAddressPoolConfig -Name bepooloutbound
97105
```
98106

99-
### Create health probe
107+
### Create a health probe
108+
109+
A health probe checks all VM instances to make sure they can send network traffic. The VM instance that fails the probe checks is removed from the load balancer until it goes back online and a probe check determines that it's healthy.
100110

101-
A health probe checks all virtual machine instances to make sure they can send network traffic. The virtual machine instance with failed probe checks is removed from the load balancer until it goes back online and a probe check determines that it's healthy. Create a health probe with [New-AzLoadBalancerProbeConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerprobeconfig?view=azps-2.6.0) to monitor the health of the virtual machines.
111+
To monitor the health of the VMs, create a health probe by using [New-AzLoadBalancerProbeConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerprobeconfig?view=azps-2.6.0).
102112

103113
```azurepowershell-interactive
104114
$probe = New-AzLoadBalancerProbeConfig -Name http -Protocol "http" -Port 80 -IntervalInSeconds 15 -ProbeCount 2 -RequestPath /
105115
```
106-
### Create load balancing rule
116+
### Create a load-balancer rule
107117

108-
A load balancer rule defines the frontend IP configuration for the incoming traffic and the backend pool to receive the traffic, along with the required source and destination port. Create a load balancer rule *myinboundlbrule* with [New-AzLoadBalancerRuleConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerruleconfig?view=azps-2.6.0) for listening to port 80 in the frontend pool *myfrontendinbound* and sending load-balanced network traffic to the backend address pool *bepoolinbound* also using port 80.
118+
A load-balancer rule defines the front-end IP configuration for the incoming traffic and the back-end pool to receive the traffic. It also defines the required source and destination port.
109119

110-
>[!NOTE]
111-
>This load balancing rule disables automatic outbound (S)NAT as a result of this rule with the **-DisableOutboundSNAT** parameter. Outbound NAT is only provided by the outbound rule.
120+
Create a load-balancer rule named *myinboundlbrule* by using [New-AzLoadBalancerRuleConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancerruleconfig?view=azps-2.6.0). This rule will listen to port 80 in the front-end pool *myfrontendinbound*. It will also use port 80 to send load-balanced network traffic to the back-end address pool *bepoolinbound*.
112121

113122
```azurepowershell-interactive
114123
$inboundRule = New-AzLoadBalancerRuleConfig -Name inboundlbrule -FrontendIPConfiguration $frontendIPin -BackendAddressPool $bepoolin -Probe $probe -Protocol "Tcp" -FrontendPort 80 -BackendPort 80 -IdleTimeoutInMinutes 15 -EnableFloatingIP -LoadDistribution SourceIP -DisableOutboundSNAT
115124
```
116125

117-
### Create outbound rule
126+
>[!NOTE]
127+
>This load-balancing rule disables automatic outbound secure NAT (SNAT) because of the **-DisableOutboundSNAT** parameter. Outbound NAT is provided only by the outbound rule.
128+
129+
### Create an outbound rule
130+
131+
An outbound rule defines the front-end public IP, which is represented by the front-end *myfrontendoutbound*. This front end will be used for all outbound NAT traffic as well as the back-end pool to which the rule applies.
118132

119-
An outbound rule defines the frontend public IP, represented by the frontend *myfrontendoutbound*, which will be used for all outbound NAT traffic as well as the backend pool to which this rule applies. Create an outbound rule *myoutboundrule* for outbound network translation of all virtual machines (NIC IP configurations) in *bepool* backend pool. The command below also changes the outbound idle timeout from 4 to 15 minutes and allocates 10000 SNAT ports instead of 1024. Review [New-AzLoadBalancerOutboundRuleConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalanceroutboundruleconfig?view=azps-2.7.0) for more details.
133+
Use the following command to create an outbound rule *myoutboundrule* for outbound network translation of all VMs (in NIC IP configurations) in the *bepool* back-end pool. The command changes the outbound idle time-out from 4 to 15 minutes. It allocates 10,000 SNAT ports instead of 1,024. For more information, see [New-AzLoadBalancerOutboundRuleConfig](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalanceroutboundruleconfig?view=azps-2.7.0).
120134

121135
```azurepowershell-interactive
122136
$outboundRule = New-AzLoadBalancerOutBoundRuleConfig -Name outboundrule -FrontendIPConfiguration $frontendIPout -BackendAddressPool $bepoolout -Protocol All -IdleTimeoutInMinutes 15 -AllocatedOutboundPort 10000
123137
```
124-
If you don't want to use a separate outbound pool, you can change the address pool argument in the preceding command to specify *$bepoolin* instead. We recommend using separate pools for flexibility and readability of the resulting configuration.
138+
If you don't want to use a separate outbound pool, you can change the address pool argument in the preceding command to specify *$bepoolin* instead. We recommend using separate pools to make the resulting configuration flexible and readable.
125139

126-
### Create load balancer
140+
### Create a load balancer
127141

128-
Create a load balancer with the inbound IP address using [New-AzLoadBalancer](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancer?view=azps-2.6.0) named *lb* that includes an inbound frontend IP configuration and a backend pool *bepoolinbound* that is associated with the public IP address *mypublicipinbound* that you created in the preceding step.
142+
Use the following command to create a load balancer for the inbound IP address by using [New-AzLoadBalancer](https://docs.microsoft.com/powershell/module/az.network/new-azloadbalancer?view=azps-2.6.0). Name the load balancer *lb*. It should include an inbound front-end IP configuration. Its back-end pool *bepoolinbound* should be associated with the public IP address *mypublicipinbound* that you created in the preceding step.
129143

130144
```azurepowershell-interactive
131145
New-AzLoadBalancer -Name lb -Sku Standard -ResourceGroupName myresourcegroupoutbound -Location eastus -FrontendIpConfiguration $frontendIPin,$frontendIPout -BackendAddressPool $bepoolin,$bepoolout -Probe $probe -LoadBalancingRule $inboundrule -OutboundRule $outboundrule
132146
```
133147

134-
At this point, you can continue with adding your VMs to the backend pool *bepoolinbound* __and__ *bepooloutbound* by updating the IP configuration of the respective NIC resources using [Add-AzNetworkInterfaceIpConfig](https://docs.microsoft.com/cli/azure/network/lb/rule?view=azure-cli-latest).
148+
At this point, you can continue adding your VMs to both *bepoolinbound* and *bepooloutbound* back-end pools by updating the IP configuration of the respective NIC resources. Update the resource configuration by using [Add-AzNetworkInterfaceIpConfig](https://docs.microsoft.com/cli/azure/network/lb/rule?view=azure-cli-latest).
135149

136150
## Clean up resources
137151

138-
When no longer needed, you can use the [Remove-AzResourceGroup](https://docs.microsoft.com/powershell/module/az.resources/remove-azresourcegroup?view=azps-2.7.0) command to remove the resource group, load balancer, and all related resources.
152+
When you no longer need the resource group, load balancer, and related resources, you can remove them by using [Remove-AzResourceGroup](https://docs.microsoft.com/powershell/module/az.resources/remove-azresourcegroup?view=azps-2.7.0).
139153

140154
```azurepowershell-interactive
141155
Remove-AzResourceGroup -Name myresourcegroupoutbound
142156
```
143157

144158
## Next steps
145-
In this article, you created Standard load balancer, configured both inbound load balancer traffic rules, configured and health probe for the VMs in the backend pool. To learn more about Azure Load Balancer, continue to the tutorials for Azure load balancer.
159+
In this article, you created a standard load balancer, configured both inbound and outbound load-balancer traffic rules, and configured a health probe for the VMs in the back-end pool.
146160

147-
> [!div class="nextstepaction"]
148-
> [Azure Load Balancer tutorials](tutorial-load-balancer-standard-public-zone-redundant-portal.md)
161+
To learn more, continue to the [tutorials for Azure Load Balancer](tutorial-load-balancer-standard-public-zone-redundant-portal.md).

0 commit comments

Comments
 (0)