英文:
Loop appsettings in Microsoft.Web/sites/config for functionapp
问题
我尝试使用嵌套模板中的循环来添加几个自定义条目到函数应用的应用设置,如下所示...没有复制,我可以添加,但复制后出现错误消息:
{"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": []
}
],
有什么想法为什么?
英文:
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 ?
答案1
得分: 0
-
我已经为函数应用创建了嵌套模板,与您之前尝试的要求相同。
-
我也得到了相同的无效输出,请查看下方。
-
然后,我只是编辑了模板中 "properties" 参数的值。当您在 "properties" 对象内使用 "copy" 函数时,确保对象的结构保持有效。
-
Properties 对象不应该有 "copy" 字段。而是将 "copy" 函数移到较高级别,移到 "properties" 对象之外。
{
"$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" 对象。
英文:
-
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"
}
]
}
}
]
}
- The
copy
function will be applied to the entire resource block, including the "properties" object.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论