Skip to content

Commit 46c632f

Browse files
authored
Merge pull request #222661 from bmis/bmis-configure-vnet-integration-enable
adding powershell delegation - configure-vnet-integration-enable
2 parents 2ea6802 + fec6a95 commit 46c632f

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

articles/app-service/configure-vnet-integration-enable.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The subnet must be delegated to Microsoft.Web/serverFarms. If the delegation isn
3535

3636
:::image type="content" source="./media/configure-vnet-integration-enable/vnetint-app.png" alt-text="Screenshot that shows selecting VNet integration.":::
3737

38-
1. 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.
38+
1. The dropdown list contains all the virtual networks in your subscription in the same region. Select an empty pre-existing subnet or create a new subnet.
3939

4040
:::image type="content" source="./media/configure-vnet-integration-enable/vnetint-add-vnet.png" alt-text="Screenshot that shows selecting the virtual network.":::
4141

@@ -54,18 +54,45 @@ az webapp vnet-integration add --resource-group <group-name> --name <app-name> -
5454
5555
## Configure with Azure PowerShell
5656

57+
Prepare parameters.
58+
5759
```azurepowershell
58-
# Parameters
5960
$siteName = '<app-name>'
60-
$resourceGroupName = '<group-name>'
61+
$vNetResourceGroupName = '<group-name>'
62+
$webAppResourceGroupName = '<group-name>'
6163
$vNetName = '<vnet-name>'
6264
$integrationSubnetName = '<subnet-name>'
63-
$subscriptionId = '<subscription-guid>'
65+
$vNetSubscriptionId = '<subscription-guid>'
66+
```
67+
68+
> [!NOTE]
69+
> 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.
70+
71+
Check if the subnet is delegated to Microsoft.Web/serverFarms.
72+
73+
```azurepowershell
74+
$vnet = Get-AzVirtualNetwork -Name $vNetName -ResourceGroupName $vNetResourceGroupName
75+
$subnet = Get-AzVirtualNetworkSubnetConfig -Name $integrationSubnetName -VirtualNetwork $vnet
76+
Get-AzDelegation -Subnet $subnet
77+
```
6478

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
79+
If your subnet isn't delegated to Microsoft.Web/serverFarms, add delegation using below commands.
80+
81+
```azurepowershell
82+
$subnet = Add-AzDelegation -Name "myDelegation" -ServiceName "Microsoft.Web/serverFarms" -Subnet $subnet
83+
Set-AzVirtualNetwork -VirtualNetwork $vnet
84+
```
85+
86+
Configure VNet Integration.
87+
88+
> [!NOTE]
89+
> 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.
90+
91+
```azurepowershell
92+
$subnetResourceId = "/subscriptions/$vNetSubscriptionId/resourceGroups/$vNetResourceGroupName/providers/Microsoft.Network/virtualNetworks/$vNetName/subnets/$integrationSubnetName"
93+
$webApp = Get-AzResource -ResourceType Microsoft.Web/sites -ResourceGroupName $webAppResourceGroupName -ResourceName $siteName
6894
$webApp.Properties.virtualNetworkSubnetId = $subnetResourceId
95+
$webApp.Properties.vnetRouteAllEnabled = 'true'
6996
$webApp | Set-AzResource -Force
7097
```
7198

0 commit comments

Comments
 (0)