1

I want to deploy a website (Microsoft.Web/sites) resource to a existing hosting plan (Microsoft.Web/serverfarms) without having to define the sku, workersize, etc. in the ARM template. It should just use the hosting plan as-is without changing it. But the sku seems to be required for the hosting plan definition and the hosting plan definition seems to be required for the website definition.

At the moment we read the sku of the hosting plan and set it as a parameter in the ARM template, but sometimes it still triggers a scaling operation in azure and restarts all websites on the hosting plan.

Benedikt Langer
  • 417
  • 4
  • 11

1 Answers1

8

The only thing you need in the ARM Template to set the hosting plan is the resourceId of that serverFarm - that's the serverFarmId property below...

      "name": "[variables('websiteName')]",
      "type": "Microsoft.Web/sites",
      "location": "centralus",
      "apiVersion": "2015-08-01",
      "dependsOn": [ ],
      "tags": {
          "displayName": "website"
      },
      "properties": {
          "name": "[variables('websiteName')]",
          "serverFarmId": "[resourceId(parameters('serverFarmResourceGroupName'), 'Microsoft.Web/serverFarms', parameters('AppSvcPlanName'))]"
      }

That's barebones, but it will put a web app into the existing serverFarm.

bmoore-msft
  • 8,376
  • 20
  • 22
  • I think my problem was, that I dind't provide the serverFarmResourceGroupName parameter in the resourceId function for the serverFarmId, which seems to only work when the serverFarm is defined in the same template. – Benedikt Langer Oct 28 '16 at 13:37
  • 1
    yep, you nailed - if a parameter to a function isn't supply it defaults to the current on (subscriptionId works the same way in the resourceId() fn) – bmoore-msft Nov 01 '16 at 18:51
  • @bmoore-msft - Why does putting the same thing (ServerFarmId) under `dependsOn` give error? – Pranav Jituri Jul 11 '17 at 00:53
  • 2
    dependsOn is *only* for resources defined in the same template. – bmoore-msft Jul 11 '17 at 15:32