This article is contributed. See the original author and article here.

App Service are powerful features to retrieve Azure computer resources as PaaS platform. In other hands, PaaS is shared services for multi-tenant, so it might be caused as issues to collaborate with legacy applications. As one of such issues, external services sometimes require to fixed IP addresses from your applications. It was not allowed to fix outbound IPs for App Services in past, because the IPs are randomly selected by runtime from assigned ones like below.


daisami_0-1620117755181.png


In addition that, the outbound IPs might be changed. Refer to Inbound and outbound IP addresses in Azure App Service for the detail.


 


Here is brief architecture to fix outbound IPs for App Service. It’s required to utilize NAT Gateway and VNet Integration of App Service. You can fix outbound IP as Public IP on NAT Gateway by using this architecture.


daisami_0-1620116452111.png


Follow steps below to setup.



  1. Create VNET and NAT Gateway

  2. Associate NAT Gateway to a subnet 

  3. Enable VNet Integration

  4. Setup WEBSITE_VNET_ROUTE_ALL = 1

  5. Confirm outbound IP with Kudu


You can setup to fix outbound IP on your App Service by following this post.


 


1. Create VNET and NAT Gateway


Follow Quickstart: Create a virtual network using the Azure portal to create a VNET.  Next, Create NAT Gateway by following Tutorial: Create a NAT gateway using the Azure portal. It’s required to specify Public IP like below and the Public IP will be an outbound IP for your App Service.


daisami_2-1620117141032.png


 


2. Associate NAT Gateway to a subnet 


It’s required to integrate your App Service with VNET to utilize NAT Gateway, so visit your NAT Gateway and choose “Subnets” menu from left side. Choose a subnet which your will enable VNet Integration for your App Service in later.


daisami_3-1620117390926.png


 


3. Enable VNet Integration


Visit your App Service and enable VNet Integration by choosing a subnet which you have already associated NAT Gateway.


daisami_1-1620117996877.png


 


4. Setup WEBSITE_VNET_ROUTE_ALL = 1


Next, it’s also required to route all your outbound traffic to your VNET, so visit your App Service and choose configuration menu from left side. Put WEBSITE_VNET_ROUTE_ALL = 1 like below. Refer to Integrate your app with an Azure virtual network for the detail.


daisami_2-1620118481867.png


 


5. Confirm outbound IP with Kudu


App Service offers useful feature as Kudu not only development usage. Visit your App Service and open Kudo on it. Run curl command and you can confirm returned IP is same with Public IP on your NAT Gateway.


daisami_1-1620119284693.png


 

Brought to you by Dr. Ware, Microsoft Office 365 Silver Partner, Charleston SC.