azureazure-functionsazure-resource-manager

Loop appsettings in Microsoft.Web/sites/config for functionapp


I'm trying to add few custom entries using the loop in nested template for function app appsettings like below...without copy i'm able to add, with copy I have error message like

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"message":"The parameter properties has an invalid value."}]}

      "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": []
        }
      ],

any idea why ?


Solution

  • enter image description here

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

    enter image description here

    enter image description here