ARM Template for to configure App Services with new VNet Integration feature?

I tried to reach same functionality by Bicep file, finally using

virtualNetworkSubnetId:

worked for me. For example:

resource webAppName_resource 'Microsoft.Web/sites@2020-12-01' =  {
  name: '${webAppName}'
  location: location
  properties: {
    serverFarmId: appServicePlanPortalName.id
    virtualNetworkSubnetId: '${vnetDeploy_module.outputs.vnetid}/subnets/${vnetDeploy_module.outputs.subnetname}'
    siteConfig: {
      linuxFxVersion: linuxFxVersion
      minTlsVersion: minTlsVersion
      http20Enabled: http20Enabled
    }
    httpsOnly: httpsOnly
  }
}

See templates in https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.web/app-service-regional-vnet-integration.

Result in ARM is:

{
  "type": "Microsoft.Web/sites",
  "apiVersion": "2021-01-01",
  "name": "[parameters('appName')]",
  "location": "[parameters('location')]",
  "kind": "app",
  "properties": {
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
    "virtualNetworkSubnetId": "[reference(resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))).subnets[0].id]",
    "httpsOnly": true,
    "siteConfig": {
      "vnetRouteAllEnabled": true,
      "http20Enabled": true
    }
  },
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
    "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
  ]
}

I've found a working example for this on an Azure Docs GitHub post:

How do we integrate the new vnet integrartion with ARM templates?

Seems to work a different way with the new VNet integration which uses a Microsoft.Web/sites/config sub-resource named virtualNetwork instead of the Microsoft.Web/sites/virtualNetworkConnections sub-resource

As well as a few requirements that need to be set on the target subnet / vnet (described in the link). The integration piece looks something like this:

   {
      "apiVersion": "2018-02-01",
      "type": "Microsoft.Web/sites",
      "name": "[parameters('appName')]",
      "location": "[resourceGroup().location]",

...

      "resources": [
        {
          "name": "virtualNetwork",
          "type": "config",
          "apiVersion": "2018-02-01",
          "location": "[resourceGroup().location]",
          "properties": {
            "subnetResourceid": "[parameters('subnetResourceId')]",
            "swiftSupported": true
          },
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('appName'))]"
          ]
        }
      ]
   },

Apart from this I've not found much else documented, except for a reference to it in the azure-rest-api-specs which has the "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/networkConfig/virtualNetwork" endpoint defined:

azure-rest-api-specs / WebApps.json

It also seems (as the spec suggests) replacing "type": "config" with "type": "networkConfig" also works.


I've talked to a Prem Engineer of Microsoft.

The Key is to replace the Automation Template

    {
        "type": "Microsoft.Web/sites/virtualNetworkConnections",
        "apiVersion": "2018-11-01",
        "name": "[concat(parameters('sites_FelixOFA_name'), '/xxxxxxx_Functions')]",
        "location": "West Europe",
        "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('sites_FelixOFA_name'))]"
        ],
        "properties": {
            "vnetResourceId": "[concat(parameters('virtualNetworks_FelixODevPremNet_externalid'), '/subnets/Functions')]",
            "isSwift": true
        }
    }

with

{
  "type": "Microsoft.Web/sites/networkConfig",
  "name": "[concat(parameters('webAppName'),'/VirtualNetwork')]",
  "apiVersion": "2016-08-01",
  "properties":
              {
                            "subnetResourceId": "[parameters('subnetResourceId')]"
              }
}

Where subnetResourceId is the resource id of their subnet – it should look like /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}