Task 07: NAT Gateway
DOCUMENT CATEGORY: Runbook
SCOPE: NAT Gateway deployment
PURPOSE: Provide deterministic outbound internet access for management VMs
MASTER REFERENCE: Microsoft Learn - NAT Gateway
Status: Active
Overview
This task deploys an Azure NAT Gateway and associates it with the management subnet. The NAT Gateway provides deterministic outbound internet connectivity with a static public IP, eliminating SNAT port exhaustion and ensuring consistent outbound IP for allowlisting.
Execution Target: Azure-Only (control-plane API operation) Tab Profile: 3 tabs — Azure Portal · PowerShell · Azure CLI
Module: azurelocal-toolkit
File: nat-gateway.tf
Mode: Management
Components Created
| Resource | Name Pattern | Purpose |
|---|---|---|
| Public IP | pip-azrlnat-{env}-{region}-01 | NAT Gateway public IP |
| NAT Gateway | ng-azrl-{env}-{region}-01 | Outbound internet access |
| PIP Association | — | Link PIP to NAT GW |
| Subnet Association | — | Link NAT GW to management subnet |
NAT Gateway Configuration
| Setting | Value | Source |
|---|---|---|
| SKU | Standard (default) or StandardV2 (zone redundant; StandardV2 public IPs only) | landing_zone.connectivity.nat_gateway.sku (Terraform route) |
| Idle Timeout | Per config (minutes) | landing_zone.connectivity.nat_gateway.idle_timeout_minutes |
| Subnet | Management subnet | landing_zone.networks[].subnets[].name |
Prerequisites
- Task 01: Virtual Network completed — Management subnet exists
- Public IP not already consumed
Values from infrastructure.yml
The script reads these keys from infrastructure.yml (schema 5). Each key, with its type, default and example, is in the variables reference.
azure.tenant_id, azure.location, tags
landing_zone.connectivity.nat_gateway.name, .resource_group, .network, .subnets, .idle_timeout_minutes
landing_zone.networks[].name, .subscription, .resource_group, .location where the network is
landing_zone.subscriptions[].name, .id the subscription that holds the network
The Terraform route (src/terraform/modules/networking) also reads two keys added in registry 5.0.62 (schema 5.6.28, optional): landing_zone.connectivity.nat_gateway.public_ip_name (the name of the public IP of the NAT gateway) and landing_zone.connectivity.nat_gateway.sku (Standard, the default, or StandardV2).
Single Subscription Model
Landing Zone Placement
| Field | Value | Config Path |
|---|---|---|
| Subscription | Customer subscription | landing_zone.subscriptions[].id |
| Resource Group | rg-azrlmgmt-{env}-{region}-01 | landing_zone.networks[].resource_group |
| NAT Gateway Name | ng-azrl-{env}-{region}-01 | Naming convention |
| Public IP Name | pip-azrlnat-{env}-{region}-01 | Naming convention (Terraform route: landing_zone.connectivity.nat_gateway.public_ip_name) |
Execution Options
- Azure Portal
- Orchestrated Script
- Azure CLI
Azure Portal
When to use: Learning Azure Local, single deployment, prefer visual interface
Procedure
- Create Public IP:
- Search for Public IP addresses → + Create
| Field | Value |
|-------|-------|
| Name |
pip-azrlnat-{env}-{region}-01| | SKU | Standard | | Assignment | Static |
- Create NAT Gateway:
- Search for NAT gateways → + Create
| Field | Value | Source |
|-------|-------|--------|
| Name |
ng-azrl-{env}-{region}-01| Naming convention | | Region | Your region |azure.location| | Availability zone | No zone | Or zone-redundant | | Idle timeout | Per config (minutes) |landing_zone.connectivity.nat_gateway.idle_timeout_minutes|
-
Outbound IP: Select the Public IP created in Step 1
-
Subnet: Select the management subnet from the VNet
-
Review + create: Verify → Click Create
Validation
- NAT Gateway provisioning state: Succeeded
- Public IP associated
- Management subnet associated
- Outbound connectivity works from management VMs
Links
PowerShell
When to use: Run the task from a management workstation or a pipeline. The script reads
infrastructure.ymland carries no values of its own.
Script
| Script | What it does |
|---|---|
scripts/deploy/02-azure-foundation/phase-04-azure-management-infrastructure/02-manual-deployment/task-07-nat-gateway/powershell/New-NatGateway.ps1 | Creates the NAT gateway that landing_zone.connectivity.nat_gateway of infrastructure.yml describes, and puts the listed subnets behind it. Supports -WhatIf. |
Requires: PowerShell 7.
Run
./New-NatGateway.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf
Azure CLI
When to use: Run the task from a host that has the Azure CLI and not the Az PowerShell modules. The script is PowerShell 7 that calls
az; it readsinfrastructure.ymland carries no values of its own.
Script
| Script | What it does |
|---|---|
scripts/deploy/02-azure-foundation/phase-04-azure-management-infrastructure/02-manual-deployment/task-07-nat-gateway/azurecli/New-NatGateway.azcli.ps1 | Creates the NAT gateway that landing_zone.connectivity.nat_gateway of infrastructure.yml describes, and puts the listed subnets behind it, with the Azure CLI. Supports -WhatIf. |
Requires: PowerShell 7 and the Azure CLI, signed in with az login --tenant <azure.tenant_id>.
It creates a Standard public IP address (<gateway name>-pip) and the gateway, then attaches the listed subnets. A subnet that already uses a NAT gateway is reported and left alone, even when it is another one.
Run
./New-NatGateway.azcli.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf
./New-NatGateway.azcli.ps1 -InfrastructureFile ./infrastructure.yml
Validation
- NAT Gateway provisioned
- Public IP associated
- Management subnet associated
- Outbound traffic from VMs uses NAT Gateway PIP
CAF/WAF Landing Zone Model
In the CAF/WAF model, the NAT Gateway is deployed in the Connectivity subscription alongside the VNet.
Landing Zone Placement
| Field | Value | Config Path |
|---|---|---|
| Subscription | Connectivity subscription | landing_zone.subscriptions[].id |
| Resource Group | rg-azrlconn-{env}-{region}-01 | landing_zone.networks[].resource_group |
Execution Options
- Azure Portal
- Orchestrated Script
- Azure CLI
Azure Portal
Follow the same procedure as Single Subscription → Azure Portal, targeting the Connectivity subscription.
PowerShell
When to use: Run the task from a management workstation or a pipeline. The script reads
infrastructure.ymland carries no values of its own.
Script
| Script | What it does |
|---|---|
scripts/deploy/02-azure-foundation/phase-04-azure-management-infrastructure/02-manual-deployment/task-07-nat-gateway/powershell/New-NatGateway.ps1 | Creates the NAT gateway that landing_zone.connectivity.nat_gateway of infrastructure.yml describes, and puts the listed subnets behind it. Supports -WhatIf. |
Requires: PowerShell 7.
Run
./New-NatGateway.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf
Azure CLI
When to use: Run the task from a host that has the Azure CLI and not the Az PowerShell modules. The script is PowerShell 7 that calls
az; it readsinfrastructure.ymland carries no values of its own.
Script
| Script | What it does |
|---|---|
scripts/deploy/02-azure-foundation/phase-04-azure-management-infrastructure/02-manual-deployment/task-07-nat-gateway/azurecli/New-NatGateway.azcli.ps1 | Creates the NAT gateway that landing_zone.connectivity.nat_gateway of infrastructure.yml describes, and puts the listed subnets behind it, with the Azure CLI. Supports -WhatIf. |
Requires: PowerShell 7 and the Azure CLI, signed in with az login --tenant <azure.tenant_id>.
It creates a Standard public IP address (<gateway name>-pip) and the gateway, then attaches the listed subnets. A subnet that already uses a NAT gateway is reported and left alone, even when it is another one.
Run
./New-NatGateway.azcli.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf
./New-NatGateway.azcli.ps1 -InfrastructureFile ./infrastructure.yml
Validation
- NAT Gateway in Connectivity subscription
- Outbound connectivity verified
Troubleshooting
| Issue | Root Cause | Remediation |
|---|---|---|
| SNAT port exhaustion | Too many concurrent connections | Add additional public IPs to NAT GW |
| NAT GW not taking effect | Subnet not associated | Verify subnet association |
| Conflicts with load balancer | LB outbound rules take precedence | Remove LB outbound rules or use NAT GW only |
| Idle timeout too short | Connections drop prematurely | Increase idle timeout (max 120 min) |
Alternatives
The procedures in this task use the methods shown in the tabs above. The toolkit is PowerShell 7 only and has no Bash scripts. A few tasks that act on Azure also have an Azure CLI script written in PowerShell. The script status page of the toolkit lists which task has which script.
Navigation
| Previous | Up | Next |
|---|---|---|
| Task 06: NSGs | Manual Deployment Index | Task 08: Arc Gateway |
Version Control
- Created: 2025-09-15 by Hybrid Cloud Solutions
- Last Updated: 2026-03-03 by Hybrid Cloud Solutions
- Version: 4.0.0
- Tags: azure-local, nat-gateway, networking, outbound
- Keywords: NAT gateway, outbound internet, SNAT, public IP, management subnet
- Author: Hybrid Cloud Solutions
Version Control
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0.0 | 2025-03-25 | Azure Local Cloud | Initial release |