Alex Gordon
Alex Gordon

Reputation: 60882

creating a Microsoft.Web/serverfarms resource using ARM template

I have the following resource specified in my ARM template:

    {
        "type": "Microsoft.Web/serverfarms",
        "apiVersion": "2015-04-01",
        "name": "[variables('hostingPlanName')]",
        "location": "[parameters('location')]",
        "properties": {
            "name": "[variables('hostingPlanName')]",
            "computeMode": "Dynamic",
            "sku": "Dynamic"
        }
    }

I am attempting to deploy this template via:

az group deployment create --resource-group myresgroup --template-file .\template.json --parameters .\parameters.json

And I'm getting the following exception:

Deployment failed. Correlation ID: 19355715-ab4b-4eec-bec7-474c43f02f87. {
  "Code": "BadRequest",
  "Message": "The parameter sku has an invalid value.",
  "Target": null,
  "Details": [
    {
      "Message": "The parameter sku has an invalid value."
    },
    {
      "Code": "BadRequest"
    },
    {
      "ErrorEntity": {
        "ExtendedCode": "51008",
        "MessageTemplate": "The parameter {0} has an invalid value.",
        "Parameters": [
          "sku"
        ],
        "Code": "BadRequest",
        "Message": "The parameter sku has an invalid value."
      }
    }
  ],
  "Innererror": null
}

What am I doing wrong?

Upvotes: 1

Views: 2001

Answers (3)

Kiran
Kiran

Reputation: 21

The latest "apiVersion": "2016-09-01", which is different to the old one, should be specified like this.

            "sku": {
                "name": "XY1",
                "tier": "Dynamic",
                "size": "XY1",
                "family": "XY",
                "capacity": 0
            },      

Upvotes: 0

Hong Ooi
Hong Ooi

Reputation: 57697

sku is not part of properties, but a separate field. Move it out, and it should work:

{
    "type": "Microsoft.Web/serverfarms",
    "apiVersion": "2015-04-01",
    "name": "[variables('hostingPlanName')]",
    "location": "[parameters('location')]",
    "sku": "Dynamic",
    "properties": {
        "name": "[variables('hostingPlanName')]",
        "computeMode": "Dynamic"
    }
}

Upvotes: 2

Joy Wang
Joy Wang

Reputation: 42163

To create a service plan(not ASE), you could refer to the template below, it works fine on my side.

{
    "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "type": "String"
        },
        "location": {
            "type": "String"
        },
        "sku": {
            "type": "String"
        },
        "skucode": {
            "type": "String"
        },
        "workerSize": {
            "type": "String"
        },
        "workerSizeId": {
            "type": "String"
        },
        "numberOfWorkers": {
            "type": "String"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Web/serverfarms",
            "sku": {
                "Tier": "[parameters('sku')]",
                "Name": "[parameters('skuCode')]"
            },
            "kind": "",
            "name": "[parameters('name')]",
            "apiVersion": "2016-03-01",
            "location": "[parameters('location')]",
            "properties": {
                "name": "[parameters('name')]",
                "workerSize": "[parameters('workerSize')]",
                "workerSizeId": "[parameters('workerSizeId')]",
                "numberOfWorkers": "[parameters('numberOfWorkers')]",
                "reserved": false
            }
        }
    ]
}

My test Parameters:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "value": "joytestplan1"
        },
        "location": {
            "value": "Central US"
        },
        "sku": {
            "value": "Free"
        },
        "skucode": {
            "value": "F1"
        },
        "workerSize": {
            "value": "0"
        },
        "workerSizeId": {
            "value": "0"
        },
        "numberOfWorkers": {
            "value": "1"
        }
    }
}

Upvotes: 1

Related Questions