Reputation: 9
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 ?
Upvotes: 0
Views: 246
Reputation: 3448
I have created nested template for function app and same with the requirements which you have tried above.
I also got the same invalid output check below.
Then, I just edited the value of the "properties" parameter in the template. When you use the "copy" function within the "properties" object, you need to make sure that the structure of the object remains valid.
Properties object should not have a "copy" field. Instead of that move the "copy" function to a higher level, outside the "properties" object.
{
"$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
function will be applied to the entire resource block, including the "properties" object.Upvotes: 0