首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将存储队列服务作为可选参数时出现ARM模板错误

将存储队列服务作为可选参数时出现ARM模板错误
EN

Stack Overflow用户
提问于 2020-09-10 02:37:11
回答 1查看 171关注 0票数 0

我尝试将队列服务部署为默认为空值的可选参数,模板首先创建存储帐户,然后将队列服务作为嵌套资源。模板引发错误默认模板验证失败:‘Message=Deployment’行'91‘列'9’处的模板资源'[concat(parameters('storageName'),'/default/',parameters('storagequeues')copyIndex())]‘无效:语言表达式属性数组索引'0’越界。

由于某种原因,模式在条件求值之前验证嵌套的资源名称。这是预期的行为吗?如果不是,请建议解决方法。

我试过条件" condition ":"not(contains(parameters('storagequeues'),'none'))",如果defaultvalue=为“none”,那么它将不会创建队列。它工作得很好,但这不是我们想要的方式。

EN

回答 1

Stack Overflow用户

发布于 2020-09-10 17:06:03

该模板在存储帐号下创建队列,可以满足您的需求。

代码语言:javascript
复制
{
  "$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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63817644

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档