|
| 1 | +--- |
| 2 | +title: Enable integration with Azure virtual network. |
| 3 | +description: This how-to article will walk you through enabling virtual network integration on an App Service Web App |
| 4 | +keywords: vnet integration |
| 5 | +author: madsd |
| 6 | +ms.author: madsd |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 10/20/2021 |
| 9 | +--- |
| 10 | + |
| 11 | +# Enable virtual network integration in Azure App Service |
| 12 | + |
| 13 | +Through integrating with an Azure virtual network (VNet) from your [App Service app](./overview.md), you can reach private resources from your app within the virtual network. The VNet Integration feature has two variations: |
| 14 | + |
| 15 | +* Regional VNet integration: Connect to Azure virtual networks in the same region. You must have a dedicated subnet in the VNet you're integrating with. |
| 16 | +* Gateway-required VNet integration: When you connect directly to VNet in other regions or to a classic virtual network in the same region, you must use the gateway-required VNet integration. |
| 17 | + |
| 18 | +This how-to article will describe how to set up regional VNet integration. |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +The VNet Integration requires: |
| 23 | +- An App Service pricing tier [supporting VNet integration](./overview-vnet-integration.md). |
| 24 | +- A virtual network in the same region with an empty subnet. |
| 25 | + |
| 26 | +The subnet must be delegated to Microsoft.Web/serverFarms. If the delegation isn't done before integration, the provisioning process will configure this delegation. The subnet must be allocated an IPv4 `/28` block (16 addresses). It is actually recommended to have a minimum of 64 addresses (IPv4 `/26` block) to allow for maximum horizontal scale. |
| 27 | + |
| 28 | +## Configure in the Azure portal |
| 29 | + |
| 30 | +1. Go to the **Networking** UI in the App Service portal. Under **Outbound Traffic**, select **VNet integration**. |
| 31 | + |
| 32 | +1. Select **Add VNet**. |
| 33 | + |
| 34 | + :::image type="content" source="./media/configure-vnet-integration-enable/vnetint-app.png" alt-text="Select VNet Integration"::: |
| 35 | + |
| 36 | +1. The drop-down list contains all of the virtual networks in your subscription in the same region. |
| 37 | + |
| 38 | + :::image type="content" source="./media/configure-vnet-integration-enable/vnetint-add-vnet.png" alt-text="Select the VNet"::: |
| 39 | + |
| 40 | + * Select an empty pre-existing subnet or create a new subnet. |
| 41 | + |
| 42 | +During the integration, your app is restarted. When integration is finished, you'll see details on the VNet you're integrated with. |
| 43 | + |
| 44 | +## Configure with Azure CLI |
| 45 | + |
| 46 | +You can also configure VNet integration using Azure CLI: |
| 47 | + |
| 48 | +```azurecli-interactive |
| 49 | +az webapp vnet-integration add --resource-group <group-name> --name <app-name> --vnet <vnet-name> --subnet <subnet-name> |
| 50 | +``` |
| 51 | + |
| 52 | +> [!NOTE] |
| 53 | +> The command will check if subnet is delegated to Microsoft.Web/serverFarms and apply the necessary delegation if this is not configured. If this has already been configured, and you do not have permissions to check this, or the virtual network is in another subscription, you can use the `--skip-delegation-check` parameter to bypass the validation. |
| 54 | +
|
| 55 | +## Configure with Azure PowerShell |
| 56 | + |
| 57 | +```azurepowershell |
| 58 | +# Parameters |
| 59 | +$siteName = '<app-name>' |
| 60 | +$resourceGroupName = '<group-name>' |
| 61 | +$vNetName = '<vnet-name>' |
| 62 | +$integrationSubnetName = '<subnet-name>' |
| 63 | +$subscriptionId = '<subscription-guid>' |
| 64 | +
|
| 65 | +# Configure VNet Integration |
| 66 | +$subnetResourceId = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.Network/virtualNetworks/$vNetName/subnets/$integrationSubnetName" |
| 67 | +$webApp = Get-AzResource -ResourceType Microsoft.Web/sites -ResourceGroupName $resourceGroupName -ResourceName $siteName |
| 68 | +$webApp.Properties.virtualNetworkSubnetId = $subnetResourceId |
| 69 | +$webApp | Set-AzResource -Force |
| 70 | +``` |
| 71 | + |
| 72 | +## Next steps |
| 73 | + |
| 74 | +- [Configure VNet integration routing](./configure-vnet-integration-routing.md) |
| 75 | +- [General Networking overview](./networking-features.md) |
0 commit comments