Reputation: 3746
I have to deploy 2 resources and I have an ARM Template as follows:
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 looks as follows:
Test.json
"resources":
{
"apiVersion": "2018-02-01",
"type": "Microsoft.Web/sites",
"name": "",
"properties": {
"appSettings": {
//set secrets in this section
}
}
I need to set (i) secretA, secretB in appSettings for Resource1 (ii) secretC, secretD, secretE in appsettings for Resource2.
How do I update the above ARM templates to deploy both Resource1 and Resource2 with correct secrets in appSettings?
eg:
Resource1 appSettings should look like this:
"appSettings": {
{
"name": "secretA",
"value": ""
},
{
"name": "secretB",
"value": ""
}
}
Resource2 appSettings should look like this:
"appSettings": {
{
"name": "secretC",
"value": ""
},
{
"name": "secretD",
"value": ""
},
{
"name": "secretE",
"value": ""
}
}
Upvotes: 1
Views: 1511
Reputation: 15629
You can add an array parameter. For example
parameters for resource1 as follows
"parameters": {
"secretSettings": {
"value": [
{
"name": "secretA",
"value": "",
"slotSetting": false
},
{
"name": "secretB",
"value": "",
"slotSetting": false
}
]
}
}
parameters for resource2 as follows
"parameters": {
"secretSettings": {
"value": [
{
"name": "secretC",
"value": "",
"slotSetting": false
},
{
"name": "secretD",
"value": "",
"slotSetting": false
}
]
}
}
Then you can refer to the parameter in the resource template.
"appSettings": "[parameters('secretSettings')]"
Please help me understand - what do you mean by set all the appSettings each time you deploy test.json?
This means that the new appSettings will override the existing appSettings, you should add all the appSettings you need in the parameter each time you deploy.
Upvotes: 1