【发布时间】:2020-06-21 10:20:29
【问题描述】:
我必须部署 2 个资源,并且我有一个 ARM 模板,如下所示:
Template.json
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "Resource1",
"properties": {
"templateLink": {
"uri": "Test.json"
},
"parameters": {
"secretA": { "value": "" },
"secretB": { "value": "" }
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "Resource2",
"properties": {
"templateLink": {
"uri": "Test.json"
},
"parameters": {
"secretC": { "value": "" },
"secretD": { "value": "" },
"secretE": { "value": "" }
}
}
}
Test.json 如下所示:
Test.json
"resources":
{
"apiVersion": "2018-02-01",
"type": "Microsoft.Web/sites",
"name": "",
"properties": {
"appSettings": {
//set secrets in this section
}
}
我需要在 appSettings 中为 Resource1 设置 (i) secretA、secretB (ii) 在 appsettings 中为 Resource2 设置 secretC、secretD、secretE。
如何更新上述 ARM 模板以在 appSettings 中使用正确的机密部署 Resource1 和 Resource2?
例如:
Resource1 appSettings 应如下所示:
"appSettings": {
{
"name": "secretA",
"value": ""
},
{
"name": "secretB",
"value": ""
}
}
Resource2 appSettings 应如下所示:
"appSettings": {
{
"name": "secretC",
"value": ""
},
{
"name": "secretD",
"value": ""
},
{
"name": "secretE",
"value": ""
}
}
【问题讨论】:
-
是的。您需要查看链接的手臂模板。
-
您已经有秘密 A、B、C 或者您需要在模板中创建它们?
-
我已经有秘密可用了。我需要根据 Resource 将正确的秘密传递给 appSettings。
-
模板是声明性的,所以当你设置 appSettings 属性时,你会得到的只是秘密的一个子集......所以 Resource2 将替换 Resource1 的设置。如果您想在同一部署中“添加”,则需要在每次部署 test.json 时设置 all appSettings - 这是您的方案吗?
-
请帮助我理解 - 每次部署 test.json 时设置所有 appSettings 是什么意思?
标签: azure azure-functions azure-resource-manager arm-template azure-function-app