
我尝试将队列服务部署为默认为空值的可选参数,模板首先创建存储帐户,然后将队列服务作为嵌套资源。模板引发错误默认模板验证失败:‘Message=Deployment’行'91‘列'9’处的模板资源'[concat(parameters('storageName'),'/default/',parameters('storagequeues')copyIndex())]‘无效:语言表达式属性数组索引'0’越界。
由于某种原因,模式在条件求值之前验证嵌套的资源名称。这是预期的行为吗?如果不是,请建议解决方法。
我试过条件" condition ":"not(contains(parameters('storagequeues'),'none'))",如果defaultvalue=为“none”,那么它将不会创建队列。它工作得很好,但这不是我们想要的方式。
发布于 2020-09-10 17:06:03
该模板在存储帐号下创建队列,可以满足您的需求。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the Azure Storage account."
}
},
"queueName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the blob container."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Specifies the location in which the Azure Storage resources should be deployed."
}
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot"
},
"resources": [
{
"type": "queueServices/queues",
"apiVersion": "2019-06-01",
"name": "[parameters('queueName')]",
"dependsOn": [
"[parameters('storageAccountName')]"
]
}
]
}
]
}我以前见过这个'The language expression property array index '0' is out of bounds.'错误,但原因可能不同。我在'storagequeue'中看不到你的defaultValue,可能是空数组导致了这个问题。你可以参考this。
https://stackoverflow.com/questions/63817644
复制相似问题