Skip to content

Commit 89260dc

Browse files
authored
Merge pull request #285313 from mbender-ms/lb-ado300590
load balancer - update - load-balancer-nat-pool-migration.md
2 parents b71eb1b + 61d985b commit 89260dc

File tree

1 file changed

+145
-50
lines changed

1 file changed

+145
-50
lines changed

articles/load-balancer/load-balancer-nat-pool-migration.md

Lines changed: 145 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,178 @@
11
---
2-
title: Azure Load Balancer NAT Pool to NAT Rule Migration
3-
description: Process for migrating NAT Pools to NAT Rules on Azure Load Balancer.
2+
title: Migrate from Inbound NAT rules version 1 to version 2
3+
description: Learn how to migrate Azure Load balancer from inbound NAT rules version 1 to version 2.
44
services: load-balancer
5-
author: mbrat2005
5+
author: mbender-ms
66
ms.service: azure-load-balancer
77
ms.topic: how-to
8-
ms.date: 06/26/2024
9-
ms.author: mbratschun
10-
ms.custom: template-how-to, engagement-fy23
8+
ms.date: 08/22/2024
9+
ms.author: mbender
1110
---
1211

13-
# Tutorial: Migrate from Inbound NAT Pools to NAT Rules
12+
# Migrate from Inbound NAT rules version 1 to version 2
1413

15-
Azure Load Balancer NAT Pools are the legacy approach for automatically assigning Load Balancer front end ports to each instance in a Virtual Machine Scale Set. [NAT Rules](inbound-nat-rules.md) on Standard SKU Load Balancers have replaced this functionality with an approach that is both easier to manage and faster to configure.
14+
An [inbound NAT rule](inbound-nat-rules.md) is used to forward traffic from a load balancer’s frontend to one or more instances in the backend pool. These rules provide a 1:1 mapping between the load balancer’s frontend IP address and backend instances. There are currently two versions of Inbound NAT rules, version 1 and version 2.
1615

17-
## Why Migrate to NAT Rules?
16+
## NAT rule version 1
1817

19-
NAT Rules provide the same functionality as NAT Pools, but have the following advantages:
20-
* NAT Rules can be managed using the Portal
21-
* NAT Rules can leverage Backend Pools, simplifying configuration
22-
* NAT Rules configuration changes apply more quickly than NAT Pools
23-
* NAT Pools cannot be used in conjunction with user-configured NAT Rules
18+
[Version 1](inbound-nat-rules.md) is the legacy approach for assigning an Azure Load Balancer’s frontend port to each backend instance. Rules are applied to the backend instance’s network interface card (NIC). For Azure Virtual Machine Scale Sets instances, inbound NAT rules are automatically created/deleted as new instances are scaled up/down.
2419

25-
## Migration Process
20+
## NAT rule version 2
2621

27-
The migration process will create a new Backend Pool for each Inbound NAT Pool existing on the target Load Balancer. A corresponding NAT Rule will be created for each NAT Pool and associated with the new Backend Pool. Existing Backend Pool membership will be retained.
22+
[Version 2](inbound-nat-rules.md) of Inbound NAT rules provide the same feature set as version 1, with extra benefits.
2823

29-
> [!IMPORTANT]
30-
> The migration process removes the Virtual Machine Scale Set(s) from the NAT Pools before associating the Virtual Machine Scale Set(s) with the new NAT Rules. This requires an update to the Virtual Machine Scale Set(s) model, which may cause a brief downtime while instances are upgraded with the model.
24+
- Simplified deployment experience and optimized updates.
25+
- Inbound NAT rules now target the backend pool of the load balancer and no longer require a reference on the virtual machine's NIC. Previously on version 1, both the load balancer and the virtual machine's NIC needed to be updated whenever the Inbound NAT rule was changed. Version 2 only requires a single call on the load balancer’s configuration, resulting in optimized updates.
26+
- Easily retrieve port mapping between Inbound NAT rules and backend instances.
27+
- With the legacy offering, to retrieve the port mapping between an Inbound NAT rule and a virtual machine instance, the rule would need to be correlated with the virtual machine's NIC. Version 2 injects the port mapping between the rule and backend instance directly into the load balancer’s configuration.
3128

32-
> [!NOTE]
33-
> Frontend port mapping to Virtual Machine Scale Set instances may change with the move to NAT Rules, especially in situations where a single NAT Pool has multiple associated Virtual Machine Scale Sets. The new port assignment will align sequentially to instance ID numbers; when there are multiple Virtual Machine Scale Sets, ports will be assigned to all instances in one scale set, then the next, continuing.
29+
## How do I know if I’m using version 1 of Inbound NAT rules?
3430

35-
> [!NOTE]
36-
> Service Fabric Clusters take significantly longer to update the Virtual Machine Scale Set model (up to an hour).
31+
The easiest way to identify if your deployments are using version 1 of the feature is by inspecting the load balancer’s configuration. If either the `InboundNATPool` property or the `backendIPConfiguration` property within the `InboundNATRule` configuration is populated, then the deployment is version 1 of Inbound NAT rules.
3732

38-
### Prerequisites
33+
## How to migrate from version 1 to version 2?
3934

40-
* In order to migrate a Load Balancer's NAT Pools to NAT Rules, the Load Balancer SKU must be 'Standard'. To automate this upgrade process, see the steps provided in [Upgrade a Basic Load Balancer to Standard with PowerShell](upgrade-basic-standard-with-powershell.md).
41-
* Virtual Machine Scale Sets associated with the target Load Balancer must use either a 'Manual' or 'Automatic' upgrade policy--'Rolling' upgrade policy is not supported. For more information, see [Virtual Machine Scale Sets Upgrade Policies](/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-policy)
42-
* Install the latest version of [PowerShell](/powershell/scripting/install/installing-powershell)
43-
* Install the [Azure PowerShell modules](/powershell/azure/install-azure-powershell)
35+
Prior to migrating it's important to review the following information:
4436

45-
### Install the 'AzureLoadBalancerNATPoolMigration' module
37+
- Migrating to version 2 of Inbound NAT rules causes downtime to active traffic that is flowing through the NAT rules. Traffic flowing through [load balancer rules](components.md) or [outbound rules](components.md) aren't impacted during the migration process.
38+
- Plan out the max number of instances in a backend pool. Since version 2 targets the load balancer’s backend pool, a sufficient number of ports need to be allocated for the NAT rule’s frontend.
39+
- Each backend instance is exposed on the port configured in the new NAT rule.
40+
- Multiple NAT rules can’t exist if they have an overlapping port range or have the same backend port.
41+
- NAT rules and load balancing rules can’t share the same backend port.
4642

47-
Install the module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/AzureLoadBalancerNATPoolMigration)
43+
### Manual Migration
44+
45+
The following three steps need to be performed to migrate to version 2 of inbound NAT rules
46+
47+
1. Delete the version 1 of inbound NAT rules on the load balancer’s configuration.
48+
2. Remove the reference to the NAT rule on the virtual machine or virtual machine scale set configuration.
49+
1. All virtual machine scale set instances need to be updated.
50+
3. Deploy version 2 of Inbound NAT rules.
51+
52+
### Virtual Machine
53+
54+
The following steps are used to migrate from version 1 to version 2 of Inbound NAT rules for a virtual machine.
55+
56+
# [Azure CLI](#tab/azure-cli)
57+
58+
```azurecli
59+
60+
az network lb inbound-nat-rule delete -g MyResourceGroup --lb-name MyLoadBalancer --name NATruleV1
61+
62+
az network nic ip-config inbound-nat-rule remove -g MyResourceGroup --nic-name MyNic -n MyIpConfig --inbound-nat-rule MyNatRule
63+
64+
az network lb inbound-nat-rule create -g MyResourceGroup --lb-name MyLoadBalancer -n MyNatRule --protocol Tcp --frontend-port-range-start 201 --frontend-port-range-end 500 --backend-port 22
4865
49-
```azurepowershell
50-
Install-Module -Name AzureLoadBalancerNATPoolMigration -Scope CurrentUser -Repository PSGallery -Force
5166
```
5267

53-
### Use the module to upgrade NAT Pools to NAT Rules
68+
# [PowerShell](#tab/powershell)
69+
70+
```powershell
71+
72+
$slb = Get-AzLoadBalancer -Name "MyLoadBalancer" -ResourceGroupName "MyResourceGroup"
73+
74+
Remove-AzLoadBalancerInboundNatRuleConfig -Name "myinboundnatrule" -LoadBalancer $loadbalancer
75+
76+
Set-AzLoadBalancer -LoadBalancer $slb
77+
78+
$nic = Get-AzNetworkInterface -Name "myNIC" -ResourceGroupName "MyResourceGroup"
79+
80+
$nic.IpConfigurations[0].LoadBalancerInboundNatRule  = $null
81+
82+
Set-AzNetworkInterface -NetworkInterface $nic
83+
84+
$slb | Add-AzLoadBalancerInboundNatRuleConfig -Name "NewNatRuleV2" -FrontendIPConfiguration $slb.FrontendIpConfigurations[0] -Protocol "Tcp" -FrontendPortRangeStart 201-FrontendPortRangeEnd 500 -BackendAddressPool $slb.BackendAddressPools[0] -BackendPort 22
85+
$slb | Set-AzLoadBalancer
86+
87+
88+
```
89+
---
90+
91+
92+
### Virtual Machine Scale Set
93+
94+
The following steps are used to migrate from version 1 to version 2 of Inbound NAT rules for a virtual machine scale set. It assumes the virtual machine scale set's upgrade mode is set to Manual. For more information, see [Orchestration modes for Virtual Machine Scale Sets in Azure](/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-orchestration-modes)
95+
96+
97+
98+
# [Azure CLI](#tab/azure-cli)
5499

55-
1. Connect to Azure with `Connect-AzAccount`
56-
1. Find the target Load Balancer for the NAT Rules upgrade and note its name and Resource Group name
57-
1. Run the migration command
100+
```azurecli
58101
59-
#### Example: specify the Load Balancer name and Resource Group name
60-
```azurepowershell
61-
Start-AzNATPoolMigration -ResourceGroupName <loadBalancerResourceGroupName> -LoadBalancerName <LoadBalancerName>
62-
```
102+
az network lb inbound-nat-pool delete  -g MyResourceGroup --lb-name MyLoadBalancer -n MyNatPool
63103
64-
#### Example: pass a Load Balancer from the pipeline
65-
```azurepowershell
66-
Get-AzLoadBalancer -ResourceGroupName <loadBalancerResourceGroupName> -Name <LoadBalancerName> | Start-AzNATPoolMigration
67-
```
104+
az vmss update -g MyResourceGroup -n MyVMScaleSet --remove virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].loadBalancerInboundNatPools
68105
69-
## Common Questions
106+
az vmss update-instances --instance-ids '*' --resource-group MyResourceGroup --name MyVMScaleSet
70107
71-
### Will migration cause downtime to my NAT ports?
108+
az network lb inbound-nat-rule create -g MyResourceGroup --lb-name MyLoadBalancer -n MyNatRule --protocol Tcp --frontend-port-range-start 201 --frontend-port-range-end 500 --backend-port 22
109+
110+
```
111+
112+
# [PowerShell](#tab/powershell)
113+
114+
```powershell
115+
116+
# Remove the Inbound NAT rule
117+
118+
$slb = Get-AzLoadBalancer -Name "MyLoadBalancer" -ResourceGroupName "MyResourceGroup"
119+
120+
Remove-AzLoadBalancerInboundNatPoolConfig -Name myinboundnatpool -LoadBalancer $slb
121+
122+
Set-AzLoadBalancer -LoadBalancer $slb
123+
124+
# Remove the Inbound NAT pool association
125+
126+
$vmss = Get-AzVmss -ResourceGroupName "MyResourceGroup" -VMScaleSetName "MyVMScaleSet"
127+
128+
$vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].loadBalancerInboundNatPools = $null
129+
130+
# Upgrade all instances in the VMSS
131+
132+
Update-AzVmssInstance -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssName -InstanceId "*"
133+
134+
$slb | Add-AzLoadBalancerInboundNatRuleConfig -Name "NewNatRuleV2" -FrontendIPConfiguration $slb.FrontendIpConfigurations[0] -Protocol "Tcp" -FrontendPortRangeStart 201-FrontendPortRangeEnd 500 -BackendAddressPool $slb.BackendAddressPools[0] -BackendPort 22
135+
$slb | Set-AzLoadBalancer
136+
137+
```
138+
---
139+
140+
## Migration with automation script for Virtual Machine Scale Set
141+
142+
143+
### Prerequisites
144+
145+
Before beginning the migration process, ensure the following prerequisites are met:
146+
147+
- The load balancer's SKU must be **Standard** to migrate a load balancer's NAT Pools to NAT Rules. To automate this upgrade process, see the steps provided in [Upgrade a Basic Load Balancer to Standard with PowerShell](upgrade-basic-standard-with-powershell.md).
148+
- The Virtual Machine Scale Sets associated with the target Load Balancer must use either a 'Manual' or 'Automatic' upgrade policy--'Rolling' upgrade policy isn't supported. For more information, see [Virtual Machine Scale Sets Upgrade Policies](/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-policy).
149+
- Install the latest version of [PowerShell](/powershell/scripting/install/installing-powershell).
150+
- Install the [Azure PowerShell modules](/powershell/azure/install-azure-powershell).
151+
152+
### Install the `AzureLoadBalancerNATPoolMigration` module
153+
154+
With the following command, install the `AzureLoadBalancerNATPoolMigration` module from the PowerShell Gallery:
155+
156+
```powershell
157+
# Install the AzureLoadBalancerNATPoolMigration module
158+
159+
Install-Module -Name AzureLoadBalancerNATPoolMigration -Scope CurrentUser -Repository PSGallery -Force
160+
```
72161

73-
Yes, because we must first remove the NAT Pools before we can create the NAT Rules, there will be a brief time where there is no mapping of the front end port to a back end port.
162+
### Upgrade NAT Pools to NAT Rules
74163

75-
> [!NOTE]
76-
> Downtime for NAT'ed port on Service Fabric clusters will be significantly longer--up to an hour for a Silver cluster in testing.
164+
With the `azureLoadBalancerNATPoolMigration` module installed, upgrade your NAT Pools to NAT Rules with the following steps:
77165

78-
### Do I need to keep both the new Backend Pools created during the migration and my existing Backend Pools if the membership is the same?
166+
1. Connect to Azure with `Connect-AzAccount`.
167+
2. Collect the names of the **target load balancer** for the NAT Rules upgrade and its **Resource Group** name.
168+
3. Run the migration command with your resource names replacing the placeholders of `<loadBalancerResourceGroupName>` and `<loadBalancerName>`:
79169

80-
No, following the migration, you can review the new backend pools. If the membership is the same between backend pools, you can replace the new backend pool in the NAT Rule with an existing backend pool, then remove the new backend pool.
170+
```powershell
171+
# Run the migration command
172+
173+
Start-AzNATPoolMigration -ResourceGroupName <loadBalancerResourceGroupName> -LoadBalancerName <loadBalancerName>
174+
175+
```
81176
82177
## Next steps
83178

0 commit comments

Comments
 (0)