Manage network policies for private endpoints
By default, network policies are disabled for a subnet in a virtual network. To use network policies like User-Defined Routes (UDRs) and Network Security Groups support, network policy support must be enabled for the subnet. This setting is only applicable to private endpoints in the subnet, and affects all private endpoints in the subnet. For other resources in the subnet, access is controlled based on security rules in the network security group.
Network policies can be enabled either for Network Security Groups only, for User-Defined Routes only, or for both.
If you enable network security policies for User-Defined Routes, you can use a custom address prefix equal to or larger than the VNet address space to invalidate the /32 default route propagated by the private endpoint. This can be useful if you want to ensure private endpoint connection requests go through a firewall or Virtual Appliance. Otherwise, the /32 default route would send traffic directly to the private endpoint in accordance with the longest prefix match algorithm.
Important
To invalidate a Private Endpoint route, UDRs must have a prefix equal to or larger than the VNet address space where the Private Endpoint is provisioned. For example, a UDR default route (0.0.0.0/0) doesn't invalidate Private Endpoint routes. Network policies should be enabled in the subnet that hosts the private endpoint.
Use the following step to enable or disable network policy for private endpoints:
- Azure portal
- Azure PowerShell
- Azure CLI
- Azure Resource Manager templates
The following examples describe how to enable and disable PrivateEndpointNetworkPolicies
for a virtual network named myVNet with a default subnet of 10.1.0.0/24 hosted in a resource group named myResourceGroup.
Enable network policy
Sign-in to the Azure portal.
In the search box at the top of the portal, enter Virtual network. Select Virtual networks.
Select myVNet.
In settings of myVNet, select Subnets.
Select the default subnet.
In the properties for the default subnet, enable the checkboxes for "Network Security Groups", "Route tables" or both in NETWORK POLICY FOR PRIVATE ENDPOINTS.
Select Save.
Disable network policy
Sign-in to the Azure portal.
In the search box at the top of the portal, enter Virtual network. Select Virtual networks.
Select myVNet.
In settings of myVNet, select Subnets.
Select the default subnet.
In the properties for the default subnet, select Disabled in NETWORK POLICY FOR PRIVATE ENDPOINTS.
Select Save.
Important
There are limitations to private endpoints in relation to the network policy feature and Network Security Groups and User Defined Routes. For more information, see Limitations.
Next steps
- Learn more about Azure private endpoint
Feedback
Submit and view feedback for