
Azure App Service Private Endpoint is a game-changer for organizations that require enhanced security for their applications.
By creating a private endpoint, you can securely connect your Azure App Service to your virtual network, reducing exposure to the public internet.
This private connection enables you to manage access to your application using network security groups and Azure Active Directory.
Private endpoints also allow you to use private IP addresses, making it easier to integrate with your existing infrastructure.
Broaden your view: Azure App Service Security Vulnerability
Network Security
Network Security is a top priority when using Azure App Service Private Endpoints. You can't rely on the platform's default security features alone, so you need to understand the various options available.
To communicate with resources outside the network security perimeter, you'll need to use public inbound and outbound access rules. This is because Azure Network Security Perimeter (NSP) rule enforcement is primarily identity-based, which can't be fully enforced in platform services like App Services and Functions.
Private Endpoints provide a privately accessible IP address for the Azure service, but they don't necessarily restrict public network access to it. This means you'll need to implement additional access controls, such as Network Security Groups (NSG), User Defined Routes (UDR), and Application Security Groups (ASG).
You can use network policies to enable support for these additional security features. For example, you can configure an Application Security Group (ASG) with a private endpoint to further restrict access to your resources.
Here's a summary of the key network security features you should consider when using Private Endpoints:
By implementing these network security features, you can ensure that your resources are properly protected and only accessible to authorized parties.
Service Environment
An App Service Environment (ASE) is a single-tenant deployment of the Azure App Service that runs in your virtual network. This allows you to access resources in your virtual network, across ExpressRoute, and expose your apps with a private address in your virtual network.
Some benefits of using an ASE include hosting your apps in a single-tenant service, scaling up to many more instances than possible in the multi-tenant service, and loading private CA client certificates for use by your apps with private CA-secured endpoints.
To enable private endpoint for apps hosted in an IsolatedV2 plan (App Service Environment v3), you need to enable the private endpoint support at the App Service Environment level. This can be done through the Azure portal or the CLI.
Here are some things to consider when using an ASE:
- An ASE runs inside your virtual network but has dependencies outside the virtual network that must be allowed.
- An ASE doesn't scale immediately like the multi-tenant service and requires anticipating scaling needs.
- An ASE has a higher up-front cost and is best suited for large workloads.
- The apps in an ASE can't selectively restrict access to some apps in the ASE and not others.
Service Environment
An App Service Environment (ASE) is a single-tenant deployment of the Azure App Service that runs in your virtual network. It's a great option for accessing resources in your virtual network, across ExpressRoute, or exposing your apps with a private address in your virtual network.
You can access resources in your virtual network without any extra configuration. If you want to access resources like SQL or Azure Storage over service endpoints, enable service endpoints on the ASE subnet.
An ASE provides the best story around isolated and dedicated app hosting, but it does involve some management challenges. An ASE runs inside your virtual network, but it does have dependencies outside the virtual network that must be allowed.
To use an operational ASE, you need to consider the following: an ASE doesn't scale immediately like the multi-tenant service, you need to anticipate scaling needs rather than reactively scaling. An ASE also has a higher up-front cost, so you should plan to put many workloads into one ASE rather than using it for small efforts.
Here are some things that aren't currently possible from the multi-tenant service but are possible from an ASE:
- Host your apps in a single-tenant service.
- Scale up to many more instances than are possible in the multi-tenant service.
- Load private CA client certificates for use by your apps with private CA-secured endpoints.
- Force TLS 1.2 across all apps hosted in the system without any ability to disable it at the app level.
Create Multi-Tier
Creating a multi-tier application is a great way to secure your API back-end apps. You can connect your front-end web app to a subnet in a virtual network using virtual network integration.
To start, you'll need to decide how to lock down access to your API application. You can host both the front end and the API app in the same ILB ASE, or host the front end in the multi-tenant service and the back end in an ILB ASE.
Worth a look: Azure Application Gateway
Here are some options to consider:
If you choose to host both the front end and API app in the same ILB ASE, you can expose your API application using private endpoints in your virtual network.
Worth a look: Azure Api Apps
Virtual Network
You can put your App Service into a virtual network by creating an application gateway with private inbound and outbound addresses, securing inbound traffic with service endpoints, and using the virtual network integration feature. This deployment style won't give you a dedicated address for outbound traffic to the internet or the ability to lock down all outbound traffic from your app, but it will give you a lot of what you would only otherwise get with an App Service Environment (ASE).
To integrate your App Service with a virtual network, you'll need to configure the DNS servers to use the DNS servers of your virtual network, which can be done in the Azure Portal by navigating to the Virtual Network and opening the DNS servers pane. You'll also need to verify or configure custom DNS servers for your virtual network if you're using a custom DNS server to resolve your private namespace.
By integrating your App Service with a virtual network, you'll be able to use the DNS servers of your virtual network to perform name resolution, which is especially useful if you're using a custom DNS server to resolve your private namespace.
A different take: Azure Virtual Network Dns Servers
Virtual Network
To put an app into a virtual network, you can use an Azure Service Environment (ASE) or combine features in the multi-tenant service.
Creating an application gateway with private inbound and outbound addresses is a good starting point. You can also secure inbound traffic to your app with service endpoints and use the virtual network integration feature to keep the back end of your app in your virtual network.
A dedicated address for outbound traffic to the internet or the ability to lock down all outbound traffic from your app is not provided by this deployment style, but it gives you most of what you would otherwise get with an ASE.
To integrate your app with a virtual network, you'll need to configure custom DNS servers for your virtual network. In the Azure Portal, navigate to the Virtual Network you'll use to integrate your app, open the DNS servers pane, and verify that you have a Custom list of suitable DNS servers.
You can add one DNS server IP address per line and click Save when you're done. This will allow your app to use the DNS servers of your virtual network to perform name resolution.
Here are the steps to configure custom DNS servers for your virtual network:
- In the Azure Portal, navigate to the Virtual Network you will use to integrate your app.
- Open the DNS servers pane.
- Verify that you have a Custom list of suitable DNS servers.
- If you need to change or update the list, add one DNS server IP address per line and click Save when you’re done.
The DNS settings you use to connect to a private-link resource are important. You may need to configure separate DNS settings for private endpoints, which often require private DNS zones.
The network interface associated with the private endpoint contains the information needed to configure your DNS. This includes the FQDN and private IP address for a private-link resource.
You can find complete information about recommendations to configure DNS for private endpoints in the Private endpoint DNS configuration article.
Diagram
In an Azure Virtual Network, an App Service with a private link endpoint can be deployed.
A private custom domain name is also used in this setup.
The private endpoint's DNS entry is duplicated from the Private Azure DNS Zone privatelink.azurewebsites.net.
At scale, forwarding on-premises DNS requests for Private Link zones to Azure DNS might be preferred.
Dns
DNS plays a crucial role in Azure App Service private endpoint configuration. You must ensure that your DNS settings are correct when using the fully qualified domain name (FQDN) for the connection, as it must resolve to the private IP address of the private endpoint.
Existing Azure services might already have a DNS configuration you can use when connecting over a public endpoint, but separate DNS settings are required for private endpoint connections. You can find the necessary information in the network interface associated with the private endpoint, which includes the FQDN and private IP address for the private-link resource.
The DNS zone that you need to create is privatelink.azurewebsites.net. You must register a record for your app with an A record and the private endpoint IP.
Here's an example of the name resolution after DNS configuration:
You must use the default name mywebapp.azurewebsites.net to reach your app privately, as the default certificate is issued for *.azurewebsites.net. If you need to use a custom DNS name, you must add the custom name in your app and validate it using public DNS resolution.
Best Practices and Considerations
When creating a private endpoint for Azure App Service, it's essential to consider a few key factors to ensure a smooth and secure experience.
First and foremost, you should be aware that outbound traffic denied from a private endpoint isn't a valid scenario, as the service provider can't originate traffic. This means that if you're trying to restrict traffic from your private endpoint, you'll need to configure your network settings accordingly.
To keep your private endpoint secure, controlled, and easy to manage, consider implementing a few best practices. One of the most effective ways to do this is to use a dedicated subnet for your private endpoints, which helps isolate them from other traffic in your virtual network.
Another crucial step is to enable Private Link on your Azure Functions app, as this is required to connect to the private endpoint. You should also use a service tag to control access to your private endpoints, ensuring that only authorized users can access them.
Curious to learn more? Check out: Traffic Manager in Azure
Monitoring your private endpoints is also vital, and you can use Azure Monitor to ensure they're working correctly. Regularly updating your private endpoints is also essential to ensure they're using the latest security features.
Here are some additional options to consider:
- Use a private DNS zone to resolve the private endpoint's IP address.
- Use a load balancer to distribute traffic to your Azure Functions app.
- Use a firewall to control access to your Azure Functions app.
To avoid common mistakes, make sure to use the correct subscription and resource group when creating your private endpoint, and ensure that it's created in the same subnet as your Azure Functions app.
Domain and Alias
You can connect to a private-link service by using an alias, which is a unique moniker generated when a service owner creates a private-link service behind a standard load balancer.
To use the alias, create a private endpoint by using the manual connection approval method, which involves setting the manual request parameter to True during the private-endpoint create flow.
A private endpoint can be created using the New-AzPrivateEndpoint command or the az network private-endpoint create command.
Check this out: Azure Create New App Service
Consumers can request a connection to a private-link service by using either the resource URI or the alias.
If the consumer's subscription is allow-listed on the provider side, the manual request can be auto-approved.
To use a custom domain with an App Service, you'll need to create a TXT DNS record in the public namespace for validation, even if VNet integration is enabled.
You'll also need to configure VNet integration and custom DNS servers if your App Service needs to reach other internal resources.
Here are the requirements for using a private custom domain name:
- A virtual network exists in the same region as your App Service.
- In that VNet, you have an empty subnet with a size of at least /28 available.
Once these configuration changes have been made, you can proceed to add and validate the custom domain name that only resolves in your private DNS namespace.
Steps to Create
To create a private endpoint for Azure App Service, you'll need to have an Azure subscription, an Azure resource group, a virtual network, a subnet in the virtual network, and an Azure App Service.
You'll also need to have an Azure Functions app.
Here are the basic requirements:
- Azure subscription
- Azure resource group
- Virtual network
- Subnet in the virtual network
- Azure App Service
You can then use these to create a private endpoint, which will allow you to isolate traffic between the virtual network and the Azure service from the public internet.
Frequently Asked Questions
What is the difference between app service environment and private endpoint?
App Service Environment (ASE) provides a fully isolated environment for apps, while Private Endpoints offer secure access to apps over a private endpoint, offering different levels of security and isolation
What is the difference between service endpoint and private endpoint in Azure?
Private Endpoint provides direct and secure access to Azure services, bypassing the internet, while Service Endpoint allows access through the internet with certain restrictions. This difference offers distinct security and access benefits for users.
Sources
- https://learn.microsoft.com/en-us/azure/app-service/networking-features
- https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-overview
- https://blog.aelterman.com/2022/01/10/azure-app-service-using-a-custom-domain-name-in-a-private-namespace/
- https://www.techtarget.com/searchcloudcomputing/tutorial/Create-a-private-endpoint-to-secure-Azure-Functions-apps
- https://learn.microsoft.com/en-us/azure/app-service/overview-private-endpoint
Featured Images: pexels.com