Rediger

Del via


Configure Azure NAT Gateway integration

Azure NAT Gateway is a fully managed, highly resilient service that ensures all outbound internet-facing traffic routes through a network address translation (NAT) gateway within Azure Virtual Network. You can associate your NAT gateway with one or more subnets in your Azure virtual network and provide robust support for your App Service application.

There are two important scenarios for using Azure NAT Gateway with App Service:

  • A NAT gateway gives you a static, predictable public IP address for outbound internet-facing traffic to your app within the virtual network.
  • A NAT gateway significantly increases the available source network address translation (SNAT) ports in scenarios where you have a high number of concurrent connections to the same public address/port combination. For more information, see Troubleshoot intermittent outbound connection errors in Azure App Service.

The following diagram shows internet traffic from an app flowing to a NAT gateway in an Azure virtual network:

Diagram that shows internet traffic from an app flowing to a NAT gateway in a virtual network.

This article describes how to configure Azure NAT Gateway integration with Azure App Service and Azure Virtual Network. Follow steps in the Azure portal or use the Azure CLI.

Prerequisites

Important considerations for integration

Review the following important considerations about Azure NAT Gateway integration:

  • Whether you can use a NAT gateway with App Service is dependent on virtual network integration. You must have a supported pricing tier in an App Service plan.

  • When you use a NAT gateway together with App Service, all traffic to Azure Storage must use private endpoints or service endpoints.

  • Azure NAT Gateway is supported for App Service Environment v3 only.

Prepare app with virtual network integration

Confirm your app is integrated with a virtual network and subnet, as described in Integrate your app with an Azure virtual network. Verify the network integration is enabled to route all application and configuration traffic.

  1. In the Azure portal, go to your app, and select Settings > Networking.

  2. In the Outbound traffic configuration section, confirm the Virtual network integration option is set to the desired virtual network and subnet for the integration:

    Screenshot that shows virtual network integration enabled for the app in the Azure portal.

    The Virtual network integration option value is a link to the integrated network.

    To view the details for the integrated network, select the link:

    Screenshot that shows how to select the virtual network and subnet link in the Azure portal.

  3. (As needed) If the Virtual network integration option isn't set, select the Not configured link:

    Screenshot that shows how to configure virtual network integration for an app in the Azure portal.

    1. In the Virtual Network Integration page, select Add virtual network integration:

      Screenshot that shows how to select the 'Add virtual network integration' option in the Azure portal.

    2. In the Add virtual network integration pane, select your Subscription, Virtual Network, and Subnet.

    3. Select Connect.

    The page refreshes to show the integration details for the new network connection.

  4. In the details view for the virtual network integration, confirm all traffic routes are enabled (each checkbox is selected):

    • In the Application routing section, enable the Outbound internet traffic option.

    • In the Configuration routing section, enable the Container image pull, Content storage, and Backup/restore options.

    If you make changes, select Apply.

    Screenshot that shows how to ensure all traffic routes are enabled for the integration in the Azure portal.

For detailed steps, see Configure application routing.

Create and configure an Azure NAT gateway

Create the NAT gateway with a public IP address and associate it with the subnet for virtual network integration.

Review the available Azure NAT Gateway SKUs and select the best plan for your configuration.

  1. In the Azure portal Home page, select + Create a resource.

  2. In the Create a resource page, search for NAT gateway.

  3. Locate the NAT gateway card for the Azure Service, and select Create > NAT gateway.

  4. In the Create network address translation (NAT) gateway pane, configure the settings on the Basics tab:

    • Select the Subscription to use for the new gateway.
    • Select an existing Resource group for the new gateway, or create a new one.
    • Enter a unique NAT gateway name.
    • Select the Region where your app is located.
    • Select the SKU for the NAT gateway resource. To use IPv4 IP addresses, select Standard. To use IPv4 or IPv6 IP addresses, select Standard V2.
    • Enter the TCP idle timeout value. The allowable range is 4 to 120 minutes.

    Screenshot of the Basics tab for creating a NAT gateway in the Azure portal.

  5. On the Outbound IP tab, select the public IP address to use for the gateway connection.

    Select the checkbox for an existing address in the Public IP address or Public IP prefix list.

    Screenshot of the Outbound IP tab for creating a NAT gateway in the Azure portal.

    You can also create a new IP address or IP prefix for the connection:

    1. Select the + Add public IP addresses or prefixes link.

    2. In the Manage public IP addresses and prefixes pane, select the Create a public IP address link.

      1. In the Add a public IP address dialog, enter a unique Name for the IP address.

      2. Select the IP version.

      3. Select OK.

      Screenshot that shows how to create a new public IP address in the Azure portal.

    3. Select the Create a new public IP prefix link.

      1. In the Add a public IP prefix dialog, enter a unique Name for the IP prefix.

      2. Select the IP version and choose the Prefix size.

      3. Select OK.

      Screenshot that shows how to create a new public IP prefix in the Azure portal.

    4. In the Manage public IP addresses and prefixes pane, select Save.

  6. On the Networking tab, select the Virtual network for virtual network integration, and then select the Specific subnets within the selected virtual network:

    Screenshot of the Networking tab for creating a NAT gateway in the Azure portal.

  7. Select Review + Create, and then select Create.

  8. When the NAT gateway is ready, select Go to resource group.

  9. In the Overview page for your new NAT gateway, select Settings > Outbound IP.

    The page shows the public IP address that your app uses for outbound internet-facing traffic.

    Screenshot of the Outbound IP pane for a NAT gateway in the Azure portal.

Scale your NAT gateway

You can use the same NAT gateway across multiple subnets in the same virtual network. This approach enables you to use a NAT gateway across multiple apps and App Service plans.

Azure NAT Gateway supports both public IP addresses and public IP prefixes. A NAT gateway can support up to 16 IP addresses across individual IP addresses and prefixes. Each IP address allocates 64,512 ports (SNAT ports), which allow up to 1 million available ports. For more information, see Azure NAT Gateway resource.