|
1 | 1 | --- |
2 | | -title: Enable integration with an Azure virtual network |
3 | | -description: This how-to article walks you through enabling virtual network integration on an Azure App Service web app. |
| 2 | +title: Enable Integration with Azure Virtual Network |
| 3 | +description: Enable virtual network integration on an Azure App Service web app in the Azure portal, or use the Azure CLI or Azure PowerShell. |
4 | 4 | keywords: vnet integration |
5 | 5 | author: seligj95 |
6 | 6 | ms.author: jordanselig |
7 | 7 | ms.topic: how-to |
8 | | -ms.date: 01/30/2025 |
| 8 | +ms.date: 03/05/2026 |
9 | 9 | ms.tool: azure-cli, azure-powershell |
10 | | -#customer intent: As a deployment engineer, I want to integrate web apps in Azure App Service with our Azure virtual networks. |
11 | 10 | ms.service: azure-app-service |
12 | 11 | ms.custom: |
13 | 12 | - devx-track-azurepowershell |
14 | 13 | - devx-track-azurecli |
15 | 14 | - sfi-image-nochange |
| 15 | +#customer intent: As a deployment engineer, I want to enable Azure Virtual Network integration for my Azure App Service apps, so I can access private resources from my apps within my Azure virtual network. |
16 | 16 | --- |
17 | 17 |
|
18 | 18 | # Enable virtual network integration in Azure App Service |
19 | 19 |
|
20 | | -Through integrating with an Azure virtual network from your [Azure App Service app](./overview.md), you can reach private resources from your app within the virtual network. |
| 20 | +This article describes how to integrate Azure Virtual Network with [Azure App Service](overview.md). The integration enables you to reach private resources from your App Service app within your Azure virtual network. Procedures are provided for the Azure portal, the Azure CLI, and Azure PowerShell. |
21 | 21 |
|
22 | 22 | ## Prerequisites |
23 | 23 |
|
24 | | -The virtual network integration feature requires: |
| 24 | +- An existing app created in a [dedicated Azure App Service compute pricing tier](overview-vnet-integration.md) that supports virtual network integration. |
25 | 25 |
|
26 | | -- An App Service pricing tier [that supports virtual network integration](./overview-vnet-integration.md). |
27 | | -- A virtual network in the same region with an empty subnet. |
| 26 | + - If you plan to allow inbound access via private endpoints on a subnet, public access must be disabled for the app. |
28 | 27 |
|
29 | | -The subnet must be delegated to Microsoft.Web/serverFarms. If you don't delegate before integration, the provisioning process configures this delegation. The subnet must be allocated an IPv4 `/28` block (16 addresses). We recommend that you have a minimum of 64 addresses (IPv4 `/26` block) to allow for maximum horizontal scale. |
| 28 | +- The Azure virtual network and subnet that you specify for the integration must be in the same region. |
30 | 29 |
|
31 | | -If the virtual network is in a different subscription than the app, ensure that the subscription with the virtual network is registered for the `Microsoft.Web` resource provider. The provider is registered when you create the first web app in a subscription. To explicitly register the provider, see [Register resource provider](../azure-resource-manager/management/resource-providers-and-types.md#register-resource-provider). |
| 30 | + - The subnet must be allocated an IPv4 `/28` block (16 addresses). The recommended minimum size is 64 addresses (IPv4 `/26` block), which accommodates future growth and scaling needs. |
32 | 31 |
|
33 | | -## Configure in the Azure portal |
| 32 | + - The subnet must be empty, which means no network interface cards (NICs), virtual machines, private endpoints, and so on. |
34 | 33 |
|
35 | | -1. Go to your app in the Azure portal. Select **Settings** > **Networking**. Under **Outbound traffic configuration**, next to **Virtual network integration**, select the **Not configured** link. |
| 34 | + - The subnet must be delegated to `Microsoft.Web/serverFarms`. If you don't delegate before integration, the provisioning process configures this delegation. |
| 35 | + |
| 36 | +- If the specified virtual network is in different subscription than your app, confirm the virtual network subscription is registered with the `Microsoft.Web` resource provider. |
| 37 | + |
| 38 | + The resource provider is registered when you create the first web app in a subscription. To explicitly register the provider, see [Azure resource providers and types > Register resource provider](/azure/azure-resource-manager/management/resource-providers-and-types#register-resource-provider). |
| 39 | + |
| 40 | +## Configure virtual network integration |
| 41 | + |
| 42 | +Choose your preferred configuration method for completing the virtual network integration. |
| 43 | + |
| 44 | +# [Azure portal](#tab/portal) |
| 45 | + |
| 46 | +Configure virtual network integration for an app in the Azure portal: |
| 47 | + |
| 48 | +1. Sign into the [Azure portal](https://portal.azure.com) and go to the **Overview** page for your App Service app. |
| 49 | + |
| 50 | +1. In the left menu, select **Settings** > **Networking**. The **Networking** page opens. |
| 51 | + |
| 52 | +1. Scroll to the **Outbound traffic configuration** section, locate the **Virtual network integration** option, and select the **Not configured** link. |
| 53 | + |
| 54 | + :::image type="content" source="./media/configure-vnet-integration-enable/integration-not-configured.png" border="false" alt-text="Screenshot that shows how to select the 'not configured' link for virtual network integration in the Azure portal."::: |
| 55 | + |
| 56 | + The **Virtual Network Integration** page opens. |
36 | 57 |
|
37 | 58 | 1. Select **Add virtual network integration**. |
38 | 59 |
|
39 | | - :::image type="content" source="./media/configure-vnet-integration-enable/vnetint-app.png" alt-text="Screenshot that shows selecting Virtual network integration."::: |
| 60 | + :::image type="content" source="./media/configure-vnet-integration-enable/add-virtual-network-integration.png" alt-text="Screenshot that shows how to select the 'add virtual network integration' action in the Azure portal."::: |
| 61 | + |
| 62 | + The **Add virtual network integration** page opens. |
| 63 | + |
| 64 | +1. Select the **App Service Plan** connection to use for the integration. |
| 65 | + |
| 66 | + - If your subscription has an existing plan that satisfies the integration configuration requirements, the portal displays the available `<virtual-network>/<subnet>` connection targets. |
| 67 | + |
| 68 | + - To use an existing connection, select the `<virtual-network>/<subnet>` target, and then select **Connect**. |
| 69 | + |
| 70 | + The procedure is complete. |
| 71 | + |
| 72 | + - To create a new plan for the integration, select **New connection**. |
| 73 | + |
| 74 | + The page refreshes to show the **Subscription**, **Virtual Network**, and **Subnet** options. |
| 75 | + |
| 76 | + Configure the options to create a new connection: |
| 77 | + |
| 78 | + 1. Select a **Subscription** and a **Virtual Network** by using the dropdown lists. |
| 79 | + |
| 80 | + 1. Select a **Subnet** from the dropdown list, and then select **Connect**. |
| 81 | + |
| 82 | + The dropdown list shows all the virtual networks (and subnets) in the selected subscription and in the same region. The list identifies subnets available for integration, and indicates whether they're currently in use. |
| 83 | + |
| 84 | + :::image type="content" source="./media/configure-vnet-integration-enable/add-subnet-connection.png" alt-text="Screenshot that shows how to select the subscription, virtual network, and subnet to create a new connection in the Azure portal."::: |
| 85 | + |
| 86 | +During the integration, your app restarts. When integration completes, the **Virtual Network Integration** page refreshes to show the details about the connection between the virtual network and your app. |
40 | 87 |
|
41 | | -1. Select a subscription and virtual network. |
| 88 | +:::image type="content" source="./media/configure-vnet-integration-enable/virtual-network-connection.png" alt-text="Screenshot of the virtual network integration to an app in the Azure portal."::: |
42 | 89 |
|
43 | | -1. Under **Subnet**, the dropdown list contains all the virtual networks in your subscription in the same region. Select an empty preexisting subnet or create a new subnet. Select **Connect**. |
44 | 90 |
|
45 | | - :::image type="content" source="./media/configure-vnet-integration-enable/vnetint-add-vnet.png" alt-text="Screenshot that shows selecting the virtual network."::: |
| 91 | +# [Azure CLI](#tab/azure-cli) |
46 | 92 |
|
47 | | -During the integration, your app is restarted. When integration finishes, you see details on the virtual network that you integrated with. |
| 93 | +Configure virtual network integration for an app by using the Azure CLI. The following commands assume the app and virtual network are in the same subscription. |
48 | 94 |
|
49 | | -## Configure with the Azure CLI |
| 95 | +1. Run the following command to configure virtual network integration. |
50 | 96 |
|
51 | | -You can also configure virtual network integration by using the Azure CLI: |
| 97 | + Replace the `<app-name>`, `<app-resource-group>`, `<virtual-network>`, and `<subnet>` values with your resource information. |
| 98 | + |
| 99 | + ```azurecli-interactive |
| 100 | + az webapp vnet-integration add \ |
| 101 | + --resource-group "<app-resource-group>" \ |
| 102 | + --name "<app-name>" \ |
| 103 | + --vnet "<virtual-network>" \ |
| 104 | + --subnet "<subnet>" |
| 105 | + ``` |
| 106 | + |
| 107 | +1. After the integration is complete, you can update the app configuration to route all outbound traffic through the virtual network integration: |
| 108 | + |
| 109 | + Replace the `<app-resource-group>` and `<app-name>` values with your resource information. |
| 110 | + |
| 111 | + ```azurecli-interactive |
| 112 | + az resource update \ |
| 113 | + --resource-group "<app-resource-group>" \ |
| 114 | + --name "<app-name>" \ |
| 115 | + --resource-type "Microsoft.Web/sites" \ |
| 116 | + --set properties.outboundVnetRouting.allTraffic=true |
| 117 | + ``` |
| 118 | + |
| 119 | +Review the following considerations: |
| 120 | + |
| 121 | +- If the virtual network is in a different subscription than the app, you can use the global `--subscription "<subscription-ID>"` parameter to set the current subscription context. Set the current subscription context to the subscription where the virtual network is deployed. |
| 122 | + |
| 123 | +- The command checks if the subnet is delegated to `Microsoft.Web/serverFarms`. If the subnet doesn't have this configuration, the command applies the necessary delegation. |
| 124 | + |
| 125 | +- If the subnet is configured but you don't have permissions to check it, or if the virtual network is in a different subscription from your app, you can use the `--skip-delegation-check` parameter to bypass the validation. |
| 126 | + |
| 127 | +For more information, see the [az webapp vnet-integration add](/cli/azure/webapp/vnet-integration#az-webapp-vnet-integration-add) reference. |
52 | 128 |
|
53 | | -```azurecli-interactive |
54 | | -az webapp vnet-integration add --resource-group <group-name> --name <app-name> --vnet <vnet-name> --subnet <subnet-name> |
55 | | -``` |
56 | 129 |
|
57 | | -> [!NOTE] |
58 | | -> The command checks if the subnet is delegated to Microsoft.Web/serverFarms. If it isn't configured, the command applies the necessary delegation. If the subnet was configured and you don't have permissions to check it, or if the virtual network is in another subscription, you can use the `--skip-delegation-check` parameter to bypass the validation. |
| 130 | +# [Azure PowerShell](#tab/azure-powershell) |
59 | 131 |
|
60 | | -## Configure with Azure PowerShell |
| 132 | +Configure virtual network integration for an app by using Azure PowerShell. |
61 | 133 |
|
62 | | -1. Prepare parameters. |
| 134 | +1. Prepare parameters for the procedure commands. |
| 135 | + |
| 136 | + Replace the `<subscription-GUID>`, `<app-name>`, `<app-resource-group>`, `<network-resource-group>`, `<virtual-network>`, and `<subnet>` values with your resource information. |
63 | 137 |
|
64 | 138 | ```azurepowershell |
| 139 | + # Set parameters for the procedure |
65 | 140 | $siteName = '<app-name>' |
66 | | - $vNetResourceGroupName = '<group-name>' |
67 | | - $webAppResourceGroupName = '<group-name>' |
68 | | - $vNetName = '<vnet-name>' |
69 | | - $integrationSubnetName = '<subnet-name>' |
70 | | - $vNetSubscriptionId = '<subscription-guid>' |
| 141 | + $vNetResourceGroupName = '<network-resource-group>' |
| 142 | + $webAppResourceGroupName = '<app-resource-group>' |
| 143 | + $vNetName = '<virtual-network>' |
| 144 | + $integrationSubnetName = '<subnet>' |
| 145 | + $vNetSubscriptionId = '<subscription-GUID>' |
71 | 146 | ``` |
72 | 147 |
|
73 | 148 | > [!NOTE] |
74 | | - > If the virtual network is in another subscription than webapp, you can use the `Set-AzContext -Subscription "xxxx-xxxx-xxxx-xxxx"` command to set the current subscription context. Set the current subscription context to the subscription where the virtual network was deployed. |
| 149 | + > If the virtual network is in a different subscription than the web app, you can use the `Set-AzContext -Subscription "<subscription-ID>"` command to set the current subscription context. Set the current subscription context to the subscription where the **virtual network** is deployed. |
75 | 150 |
|
76 | | -1. Check if the subnet is delegated to Microsoft.Web/serverFarms. |
| 151 | +1. Check if the subnet is delegated to `Microsoft.Web/serverFarms`: |
77 | 152 |
|
78 | 153 | ```azurepowershell |
| 154 | + # Set the virtual network for the subnet to check |
79 | 155 | $vnet = Get-AzVirtualNetwork -Name $vNetName -ResourceGroupName $vNetResourceGroupName |
| 156 | +
|
| 157 | + # Get the subnet |
80 | 158 | $subnet = Get-AzVirtualNetworkSubnetConfig -Name $integrationSubnetName -VirtualNetwork $vnet |
| 159 | +
|
| 160 | + # Check the delegation |
81 | 161 | Get-AzDelegation -Subnet $subnet |
82 | 162 | ``` |
83 | 163 |
|
84 | | -1. If your subnet isn't delegated to Microsoft.Web/serverFarms, add delegation using these commands. |
| 164 | +1. If your subnet isn't delegated to `Microsoft.Web/serverFarms`, add the delegation: |
85 | 165 |
|
86 | 166 | ```azurepowershell |
| 167 | + # Get the subnet |
87 | 168 | $subnet = Add-AzDelegation -Name "myDelegation" -ServiceName "Microsoft.Web/serverFarms" -Subnet $subnet |
| 169 | +
|
| 170 | + # Set the delegation |
88 | 171 | Set-AzVirtualNetwork -VirtualNetwork $vnet |
89 | 172 | ``` |
90 | 173 |
|
91 | | -1. Configure virtual network integration. |
| 174 | +1. Configure virtual network integration, and route all traffic through the connection: |
92 | 175 |
|
93 | 176 | ```azurepowershell |
| 177 | + # Set the subnet resource ID |
94 | 178 | $subnetResourceId = "/subscriptions/$vNetSubscriptionId/resourceGroups/$vNetResourceGroupName/providers/Microsoft.Network/virtualNetworks/$vNetName/subnets/$integrationSubnetName" |
95 | | - $webApp = Get-AzResource -ResourceType Microsoft.Web/sites -ResourceGroupName $webAppResourceGroupName -ResourceName $siteName |
96 | | - $webApp.Properties.virtualNetworkSubnetId = $subnetResourceId |
97 | | - $webApp.Properties.vnetRouteAllEnabled = 'true' |
| 179 | +
|
| 180 | + # Get the web app configuration |
| 181 | + $webApp = Get-AzResource -ResourceType "Microsoft.Web/sites" -ResourceGroupName $webAppResourceGroupName -ResourceName $siteName |
| 182 | +
|
| 183 | + # Set the subnet ID |
| 184 | + $webApp.Properties | Add-Member -NotePropertyName "virtualNetworkSubnetId" -NotePropertyValue $subnetResourceId -Force |
| 185 | +
|
| 186 | + # Set routing to all traffic |
| 187 | + $webApp.Properties | Add-Member -NotePropertyName "vnetRouteAllEnabled" -NotePropertyValue $true -Force |
| 188 | +
|
| 189 | + # Complete the integration |
98 | 190 | $webApp | Set-AzResource -Force |
99 | 191 | ``` |
100 | 192 |
|
101 | 193 | > [!NOTE] |
102 | | - > If the webapp is in another subscription than virtual network, you can use the `Set-AzContext -Subscription "xxxx-xxxx-xxxx-xxxx"` command to set the current subscription context. Set the current subscription context to the subscription where the web app was deployed. |
| 194 | + > If the virtual network is in a different subscription than the web app, you can use the `Set-AzContext -Subscription "<subscription-ID>"` command to set the current subscription context. Set the current subscription context to the subscription where the **web app** is deployed. |
| 195 | +
|
| 196 | +--- |
103 | 197 |
|
104 | 198 | ## Related content |
105 | 199 |
|
106 | | -- [Configure virtual network integration routing](./configure-vnet-integration-routing.md) |
107 | | -- [General networking overview](./networking-features.md) |
| 200 | +- [Manage Azure App Service virtual network integration routing](configure-vnet-integration-routing.md) |
| 201 | +- [Overview of App Service networking features](networking-features.md) |
0 commit comments