Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare applications for Azure deployment by generating infrastructure code, Dockerfiles, and config files.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/app-service/networking.md
1# App Service Networking23VNet integration, Private Endpoints, Access Restrictions, and Hybrid Connections.45## Feature Availability by SKU67| Feature | Free | Basic | Standard | Premium | Isolated |8|---------|:-:|:-:|:-:|:-:|:-:|9| VNet integration (outbound) | ❌ | ✅ | ✅ | ✅ | ✅ (native) |10| Private Endpoints (inbound) | ❌ | ✅ | ✅ | ✅ | ✅ |11| Access Restrictions | ✅ | ✅ | ✅ | ✅ | ✅ |12| Hybrid Connections | ❌ | 5 | 25 | 200 | 200 |13| Access to service-endpoint-protected resources | ❌ | ✅ | ✅ | ✅ | ✅ |14> Note: Service endpoints are configured on VNets/subnets and downstream services (e.g., Storage, SQL). App Service accesses them via VNet integration rather than enabling service endpoints directly on the app.1516## VNet Integration (Outbound)1718Routes outbound traffic from the app through a VNet subnet, enabling access to private resources (databases, storage, VMs).1920### Subnet Requirements2122| Requirement | Value |23|------------|-------|24| Minimum subnet size | `/26` (64 addresses) recommended |25| Delegation | `Microsoft.Web/serverFarms` |26| Dedicated | One subnet per App Service plan |2728### Bicep — VNet Integration2930```bicep31resource subnet 'Microsoft.Network/virtualNetworks/subnets@2023-11-01' = {32parent: vnet33name: 'app-service-subnet'34properties: {35addressPrefix: '10.0.1.0/26'36delegations: [37{38name: 'Microsoft.Web.serverFarms'39properties: { serviceName: 'Microsoft.Web/serverFarms' }40}41]42}43}4445resource webApp 'Microsoft.Web/sites@2024-11-01' = {46name: appName47location: location48properties: {49serverFarmId: appServicePlan.id50virtualNetworkSubnetId: subnet.id51outboundVnetRouting: {52allTraffic: true // route all outbound through VNet53}54}55}56```5758### CLI - VNet Integration5960```bash61# Configure virtual network integration62az webapp vnet-integration add --resource-group RG --name APP --vnet VNET --subnet SUBNET6364# Update app configuration to route all outbound traffic through the virtual network integration65az resource update --resource-group RG --name APP --resource-type "Microsoft.Web/sites" --set properties.outboundVnetRouting.allTraffic=true66```676869> 💡 **Tip:** Set `outboundVnetRouting.allTraffic: true` to route ALL outbound traffic through the VNet. Without this, only RFC1918 traffic is routed through the VNet.7071## Private Endpoints (Inbound)7273Expose the app on a private IP address within your VNet. Public access can be disabled entirely.7475### Bicep — Private Endpoint7677```bicep78resource privateEndpoint 'Microsoft.Network/privateEndpoints@2023-11-01' = {79name: '${appName}-pe'80location: location81properties: {82subnet: { id: privateEndpointSubnet.id }83privateLinkServiceConnections: [84{85name: '${appName}-connection'86properties: {87privateLinkServiceId: webApp.id88groupIds: ['sites']89}90}91]92}93}9495resource privateDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {96name: 'privatelink.azurewebsites.net'97location: 'global'98}99100resource dnsLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = {101parent: privateDnsZone102name: '${vnet.name}-link'103location: 'global'104properties: {105virtualNetwork: { id: vnet.id }106registrationEnabled: false107}108}109110resource privateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2023-11-01' = {111parent: privateEndpoint112name: 'default'113properties: {114privateDnsZoneConfigs: [115{116name: 'webapp-dns-zone'117properties: {118privateDnsZoneId: privateDnsZone.id119}120}121]122}123}124```125126### CLI - Private Endpoint127128```bash129# Retrieve web app resource id130id=$(az webapp show --name APP --resource-group RG --query id --output tsv)131132# Create Private Endpoint133az network private-endpoint create --connection-name CONNECTIONNAME --name private-endpoint --private-connection-resource-id $id --resource-group RG --subnet SUBNET --group-id sites --vnet-name VNET134135# Create Private DNS Zone136az network private-dns zone create --resource-group RG --name "privatelink.azurewebsites.net"137138# Link the DNS Zone to virtual network139az network private-dns link vnet create --resource-group RG --zone-name "privatelink.azurewebsites.net" --name dns-link --virtual-network VNET --registration-enabled false140141```142143> ⚠️ **Warning:** Private Endpoints require Basic (B1+) or higher tier. The private DNS zone `privatelink.azurewebsites.net` must be linked to the VNet for name resolution.144145## Access Restrictions146147Control inbound access with IP-based or service-tag rules. Available on all SKUs.148149### Bicep — Access Restrictions150151```bicep152siteConfig: {153ipSecurityRestrictions: [154{155name: 'allow-office'156priority: 100157action: 'Allow'158ipAddress: '203.0.113.0/24'159}160{161name: 'deny-all'162priority: 2147483647163action: 'Deny'164ipAddress: 'Any'165}166]167scmIpSecurityRestrictionsUseMain: true168}169```170171### CLI - Access Restrictions172173```bash174# Add restriction to allow traffic from set range used by the office175az webapp config access-restriction add --resource-group RG --name APP --rule-name 'allow-office' --action Allow --ip-address 203.0.113.0/24 --priority 100176177# Add restriction to deny access from any other address range178az webapp config access-restriction add --resource-group RG --name APP --rule-name 'deny-all' --action Deny --ip-address Any --priority 2147483647179180# Set SCM Site (Kudu) to use same access restrictions as main site181az webapp config access-restriction set -g RG -n APP --use-same-restrictions-for-scm-site true182```183184> 💡 **Tip:** Always restrict the SCM/Kudu site too. Use `scmIpSecurityRestrictionsUseMain: true` to inherit main site rules, or define separate SCM rules.185186## Hybrid Connections187188Connect to on-premises resources without VPN. Requires Basic tier or higher. Uses Hybrid Connection Manager (HCM) agent on-premises relaying through Azure Relay.189190> ⚠️ **Warning:** Each Hybrid Connection maps to a single host:port endpoint. Basic tier supports 5; Standard tier supports 25; Premium/Isolated support 200.191192## Troubleshooting193194| Issue | Cause | Fix |195|-------|-------|-----|196| Cannot reach private DB | VNet integration not enabled | Enable VNet integration; check `outboundVnetRouting.allTraffic` |197| DNS resolution fails | Private DNS zone not linked | Link `privatelink.*` DNS zone to VNet |198| Access restriction not working | Priority ordering wrong | Lower numbers = higher priority; check rule order |199| Hybrid Connection timeout | HCM not running | Verify HCM service status on-premises |200| Outbound traffic blocked | NSG rules on subnet | Allow outbound to required services in NSG |201