Azure App Service Environment – error on creating a new Web App

When creating a new Web App hosted inside an App Service Environment (ASE) via an ARM template, you may encounter the following error:

"Resource Microsoft.Web/sites 'yourapplication-web01' failed with message 'Server farm with name yourappserviceplan not found.' ". Here is the reference line in the template: "serverFarmId": "/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/yourresourceid/providers/Microsoft.Web/serverfarms/ yourappserviceplan".

(where: yourapplication-web01 = the name of your web app,  yourresourceid = the name of your resource group, yourappserviceplan = the name of your app service hosting plan)

This error comes usually from an insufficient information in the ARM template you are trying to deploy. If in a Web App deployment outside ASE it is enough to reference the hosting plan which hosts the application, within an ASE you need to specify also the information for referencing the ASE environment which includes the hosting plan:

[template segment for the web app definition]

  {

      "apiVersion": "2015-08-01",
      "name": "[parameters('siteName')]",
      "type": "Microsoft.Web/sites",
      "location": "[parameters('location')]",
      "tags": {
        "displayName": "[parameters('siteName')]"
      },
      "properties": {
        "name": "[parameters('siteName')]",
        "hostingEnvironment": "[parameters('environmentName')]",
        "hostingEnvironmentId": "[resourceId('Microsoft.Web/hostingEnvironments', parameters('environmentName'))]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
      }
    }

So for the parametering aspect, you will need to include the hosting plan name ('hostingPlanName') as well as the ASE name ('environmentName').

Note: if the web site will be deployed in a different resource group, then you will need to qualify the resource references with their resource group name:
"serverFarmId": "[resourceId(parameters('hostingPlanResourceGroupName'), 'Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"

That’s all. Have a good deployment!



Aucun commentaire:

Publier un commentaire