Azure App Service and Azure Functions can connect to an Azure Virtual Network (VNet) for private, secure communication. There are two primary methods. Regional VNet integration connects your app directly to a subnet in the same Azure region. This provides lower latency and simpler setup, making it the preferred choice for most single-region scenarios. Gateway-required VNet integration uses a VPN gateway to connect your app to a VNet in a different region or to an on-premises network. This method is necessary for cross-region connectivity but introduces more complexity and potential latency.
To securely connect your apps to other Azure Platform-as-a-Service (PaaS) resources, you can use private endpoints and service endpoints. A private endpoint creates a network interface with a private IP address from your VNet directly for a specific PaaS service, ensuring all traffic between your app and that service stays on the Microsoft backbone network. A service endpoint extends your VNet's identity to a service, allowing you to restrict access to the service from only specific subnets. You deploy these endpoints within delegated subnets to secure both inbound flows to your app and outbound flows to services like Azure Storage or Azure SQL Database.
For secure and scalable outbound internet access, you can deploy an Azure NAT Gateway on the integration subnet used by your app. The NAT gateway provides a static, public source IP address for all outbound traffic from your app and dramatically increases the number of available SNAT ports, which helps prevent connection exhaustion. To use it, you enable the Route All setting on your app's VNet integration, provision a NAT gateway with a public IP, and then associate that gateway with the integration subnet. This configuration ensures all outbound internet calls from your app originate from the NAT gateway's predictable IP.
You control network traffic using Network Security Groups (NSGs) and user-defined routes (UDRs). An NSG applied to the integration subnet acts as a firewall, allowing you to filter outbound traffic from your app based on IP address, port, and protocol. Meanwhile, UDRs let you define custom routing paths, such as forcing all outbound traffic through an Azure Firewall or an on-premises network security appliance. By combining these tools, you can enforce security policies, block unwanted traffic, and ensure that reply traffic follows the approved path back through your security controls.
A system architecture diagram showing how Azure App Service or Functions routes all outbound internet traffic through regional VNet integration into a subnet associated with an Azure NAT Gateway, which provides a static public IP and increased SNAT ports for egress to the internet.
After implementing private connectivity, you must validate that it works correctly and remains secure. Use the Network troubleshooter in the Azure portal to check the status of your VNet integration and DNS resolution. You can also test connectivity from within your app's environment using tools like PowerShell's Test-NetConnection or the tcpping utility. Ongoing monitoring and logging of network flows and security events are crucial to ensure your private connectivity configuration stays robust and effective over time.
Are you a guardian of your domain? Lean how to leverage your aptitude in security to protect Microsoft Azure technologies, with a goal of earning the Microsoft Certified: Azure Security Engineer Associate certification!
Prepare and test your skills

Prepare and test your skills

Regional VNet integration connects your app directly to a subnet in the same Azure region, providing lower latency and simpler setup. Gateway-required VNet integration uses a VPN gateway to connect to a VNet in a different region or to an on-premises network, which introduces more complexity and potential latency.
Use a private endpoint when you need a network interface with a private IP address from your VNet for a specific PaaS service, ensuring all traffic stays on the Microsoft backbone network. Use a service endpoint when you want to extend your VNet's identity to a service and restrict access from only specific subnets.
By deploying an Azure NAT Gateway on the integration subnet and enabling the Route All setting, all outbound internet calls from your app originate from the NAT gateway's static public IP address. This provides a predictable source IP and increases available SNAT ports to prevent connection exhaustion.
Use the Network troubleshooter in the Azure portal to check VNet integration and DNS resolution. You can also test connectivity from within the app's environment using PowerShell's Test-NetConnection or the tcpping utility. Ongoing monitoring and logging of network flows and security events are crucial.