3

I have created ARM template to add scale out property as per below using above template as reference

 {
  "type": "Microsoft.Web/serverfarms",
  "sku": {
    "name": "S1",
    "tier": "Standard",
    "size": "S1",
    "family": "S",
    "capacity": 1
  },
  "kind": "app",
  "name": "[variables('ServerFarm_gateway_name')]",
  "apiVersion": "2016-09-01",
  "location": "[resourceGroup().location]",
  "resources": [
    {
      "name": "[concat(variables('ServerFarm_gateway_name'),'-autoscaleout')]",
      "type": "Microsoft.Insights/autoscaleSettings",
      "apiVersion": "2015-04-01",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "[concat('Microsoft.Web/serverfarms/', variables('ServerFarm_gateway_name'))]"
      ],
      "properties": {
        "name": "[concat(variables('ServerFarm_gateway_name'),'-autoscaleout')]",
        "enabled": true,
        "targetResourceLocation": "[resourceGroup().location]",
        "profiles": [
          {
            "name": "Auto created scale condition 1",
            "capacity": {
              "minimum": "1",
              "maximum": "5",
              "default": "1"
            }
          },
          {
            "name": "{\"name\":\"Auto created scale condition\",\"for\":\"Auto created scale condition 1\"}",
            "capacity": {
              "minimum": "1",
              "maximum": "5",
              "default": "1"
            }
          }
        ]
      }
    }
  ],
  "dependsOn": []
}

It is throwing error while deploy using VSTS pipeline.

##[error]At least one resource deployment operation failed. Please list deployment operations for 
   Please see https://aka.ms/DeployOperations for usage details.
   ##[error]Details:
   ##[error]BadRequest: {
  "code": "UnsupportedRequestContent",
  "message": "Request content is not well formed or supported."
  }
  ##[error]Task failed while creating or updating the template deployment.

When I remove the resource part from template then no issue.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
learner
  • 223
  • 3
  • 19

1 Answers1

4

I believe your issue is with your understanding of how autoscaling arm template works. These should be defined as a top-level resource and reference the resource it applies to.

Your template should look something like this:

 { 
  "type": "microsoft.insights/autoscalesettings",
  "name": "[concat(variables('ServerFarm_gateway_name'),'-autoscaleout')]",
  "apiVersion": "2015-04-01",
  "location": "[resourceGroup().location]",
  "properties": {
    "profiles": [
      {
        "name": "Auto created scale condition 1",
        "capacity": {
          "minimum": "1",
          "maximum": "5",
          "default": "1"
        }
      }
    ],
    "enabled": true,
    "targetResourceUri": "[resourceId('Microsoft.Web/serverfarms', variables('ServerFarm_gateway_name'))]"
  },
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms', variables('ServerFarm_gateway_name'))]"
  ]
}
LMG
  • 1,330
  • 11
  • 21
  • Thank you! Solved my problem! But It is allowing more than 1 profile. With 1 profile working perfectly fine. Below is the error for more than 1 . BadRequest: { "code": "MultipleDefaultProfiles", "message": "The autoscale setting that you provided has '2' default profiles, you can only specify one default profile per setting." } – learner Jan 24 '20 at 11:11