使用ARM模板创建Microsoft.Web / serverfarms资源

时间:2018-12-31 22:26:52

标签: azure azure-resource-manager

我在ARM模板中指定了以下资源:

QAbstractItemModel * subModel = new QStandardItemModel(this);

我正在尝试通过以下方式部署此模板:

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

我收到以下异常:

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

我在做什么错了?

3 个答案:

答案 0 :(得分:1)

要创建服务计划(不是ASE),可以参考下面的模板,它对我而言效果很好。

{
    "$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
            }
        }
    ]
}

我的测试参数:

{
    "$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"
        }
    }
}

答案 1 :(得分:1)

sku不是properties的一部分,而是一个单独的字段。将其移出,它应该可以工作:

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

答案 2 :(得分:0)

最新的“ apiVersion”:“ 2016-09-01”与旧版本不同,应按以下方式指定。

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