未读取 Azure ARM 参数文件中的值

Value from Azure ARM parameter file is not read

我想部署 Azure 资源。模板中使用的变量在专用参数文件中声明。但是,在部署模板时出现以下错误:

New-AzResourceGroupDeployment -ResourceGroupName $resourceGroup -TemplateUri $templateUri -TemplateParameterUri $paramUri

New-AzResourceGroupDeployment : 10:13:17 - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The value for the template parameter 'sku' at line '22' and column '16' is not provided. Please see https://aka.ms/arm-deploy/#parameter-file for usage details.'.

"sku"为参数,定义为:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "sku": {
            "value": {
                "name": "Standard_B1s",
                "tier": "Standard",
                "capacity": 1
            }
        }
    }
}

而且是这样called/used

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "sku": {
            "type": "object"
        }
    },
    "variables": {},
    "resources": [
        {
            "comments": "",
            "type": "Microsoft.Compute/virtualMachineScaleSets",
            "sku": "[parameters('sku')]",
            "name": "SomeName",
            "apiVersion": "2018-06-01",
            "location": "westeurope",
            "scale": null,
            "properties": {}
        }
    ],
    "outputs": {}
}

我在不同的模板中使用这种方式调用参数没有问题。

你们中的一些人发现错误了吗?

好吧,是我的错。

我过度简化了模板,因此遗漏了一条重要信息:

我正在使用链接模板(到应用程序网关的早期部署),并在此基础上添加新资源。这个第一个部署模板也有自己的参数文件。

下面是我引用的部署资源。我忘了输入参数Link 属性。因此 ARM 无法查找参数文件并向 first 模板中的 "sku" 参数提供参数。

不幸的是,网关的模板也有一个 "sku" 参数,所以我错误地认为我的其他模板有错误。我现在将参数命名为 "skuGateway" 和 "skuScaleSet" 作为经验教训。

{
    "apiVersion": "2017-05-10",
    "name": "stack1_gw",
    "type": "Microsoft.Resources/deployments",
    "properties": {
        "mode": "Incremental",
        "templateLink": {
            "uri": "[concat(uri(deployment().properties.templateLink.uri, 'stack1_gw.json'), parameters('containerSasToken'))]",
            "contentVersion": "1.0.0.0"
        },
        "parametersLink": {
            "uri": "[concat(uri(deployment().properties.templateLink.uri, 'stack1_gw.parameters.json'), parameters('containerSasToken'))]",
            "contentVersion": "1.0.0.0"
        }
    }
}