azure 循环Microsoft.Web/sites/config中的appsettings for functionapp

r1zhe5dt  于 2023-05-18  发布在  其他
关注(0)|答案(1)|浏览(147)

我试图添加几个自定义条目使用嵌套模板中的循环功能应用程序appsettings像下面...没有副本我可以添加,与副本我有错误消息一样
{“code”:“DeploymentFailed”,“message”:“至少有一个资源部署操作失败。请列出部署操作以了解详细信息。请参阅https://aka.ms/arm-deployment-operations以了解用法详细信息。",“details”:[{“message”:“参数属性的值无效。"}]}

"resources": [
        {
          "type": "Microsoft.Web/sites/config",
          "apiVersion": "2020-06-01",
          "name": "[concat(parameters('functionAppName'),'/appsettings')]",
          "properties": {
            "FUNCTIONS_EXTENSION_VERSION": "~4",
            "WEBSITE_NODE_DEFAULT_VERSION": "6.5.0",
            "WEBSITE_RUN_FROM_PACKAGE": "1",
            "FUNCTIONS_WORKER_RUNTIME": "powershell",
            "FUNCTIONS_WORKER_RUNTIME_VERSION": "~7",
            "OperationalLogType": "OperationalRecord",
            "AuditLogType": "AuditRecord",
            "copy": [
              {
                "name": "copy1",
                "count": 3,
                "input": {
                   "name": "[concat('customentry-', copyIndex('copy1'))]"
                     }
              }
            ]
          },
          "dependsOn": []
        }
      ],

知道为什么吗

jmo0nnb3

jmo0nnb31#

  • 我已经创建了嵌套模板的功能应用程序和相同的要求,你已经尝试了上面。
  • 我也得到了同样的无效输出检查下面。

  • 然后,我只是编辑了模板中“properties”参数的值。当你在“properties”对象中使用“copy”函数时,你需要确保对象的结构保持有效。
    *Properties对象不应该有copy字段。而不是将“复制”函数移到更高的级别,在“属性”对象之外。
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "functionAppName": {
            "type": "String",
            "metadata": {
                "description": "The name of the Function App."
            }
        }
    },
    "resources": [
        {
            "type": "Microsoft.Web/sites/config",
            "apiVersion": "2020-06-01",
            "name": "[concat(parameters('functionAppName'), '/appsettings')]",
            "copy": [
                {
                    "name": "Ghost",
                    "count": 3
                }
            ],
            "properties": {
                "FUNCTIONS_EXTENSION_VERSION": "~4",
                "WEBSITE_NODE_DEFAULT_VERSION": "6.5.0",
                "WEBSITE_RUN_FROM_PACKAGE": "1",
                "FUNCTIONS_WORKER_RUNTIME": "powershell",
                "FUNCTIONS_WORKER_RUNTIME_VERSION": "~7",
                "OperationalLogType": "OperationalRecord",
                "AuditLogType": "AuditRecord",
                "appSettings": [
                    {
                        "name": "[concat('customentry-', copyIndex('appSettingsLoop'))]",
                        "value": "CustomValue"
                    }
                ]
            }
        }
    ]
}
  • copy函数将应用于整个资源块,包括“properties”对象。

相关问题