Azure ARM 模板——如何精确扩展到 2 个实例?

Azure ARM template -- how to scale out to exactly 2 instances?

我想扩展到特定的实例数。

我的模板中有以下内容:

{
  "type": "Microsoft.Web/serverfarms",
  "apiVersion": "2018-02-01",
  "name": "[parameters('name')]",
  "location": "[variables('location')]",
  "sku": {
    "name": "[parameters('sku_name')]",
    "capacity": "[parameters('sku_capacity')]"
  },
  "kind": "app",
  "properties": {
    "perSiteScaling": false,
    "maximumElasticWorkerCount": 1,
    "isSpot": false,
    "reserved": false,
    "isXenon": false,
    "hyperV": false,
    "targetWorkerCount": 0,
    "targetWorkerSizeId": 0
  }
}

sku_capacity 设置为 2,但它不起作用。没有任何效果。我该如何正确配置?

此外,如果我在 Azure 界面中设置此项并导出模板,自动缩放设置似乎不包括在内。为什么?

capacity 更改不会生效的一种情况是,如果您的应用服务计划所在的 Pricing tier 不支持横向扩展。

我有一个标准应用程序服务计划,以下模板很适合我:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "asp_name": {
            "defaultValue": "ASPResources",
            "type": "String"
        },
        "sku_capacity": {
            "defaultValue": 5,
            "type": "int"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Web/serverfarms",
            "apiVersion": "2018-02-01",
            "name": "[parameters('asp_name')]",
            "location": "South India",
            "sku": {
                "name": "S1",
                "tier": "Standard",
                "size": "S1",
                "family": "S",
                "capacity": "[parameters('sku_capacity')]"
            },
            "kind": "app",
            "properties": {
                "perSiteScaling": false,
                "maximumElasticWorkerCount": 1,
                "isSpot": false,
                "reserved": false,
                "isXenon": false,
                "hyperV": false,
                "targetWorkerCount": 0,
                "targetWorkerSizeId": 0
            }
        }
    ]
}

其他资源:App Service limits