0

Let me preface this with the fact that I am new to ARM templates. I am trying to create a template that will created a bunch of CosmosDB accounts, databases, and containers based on a config file that is fed in to the powershell script used for running in the template.

EG of config file:

 { "accounts": [ { "accountName": "testproduct", "burstCapacity": "true", "databases": [ { "dbName": "dev", "containers": [ { "containerName": "container1" }, { "containerName": "container2" } ] } ] }, { "accountName": "uatproduct", "databases": [ { "dbName": "dev", "containers": [ { "containerName": "container3" } ] } ] } ] } 

Is there any way of iterating through this in ARM? I can only consider it possible with a nested loop which obviously isn't supported. My logic is: Iterate through all containers of all databases of all accounts.

I have managed to resolve by creating a template for the account and a second one for the databases/containers, with a nested loop in the PowerShell script - but want to know if there's a way of bringing it all in line in one template?

Would greatly appreciate any tips.

1
  • Have you considered using bicep?, By using bicep, you can create an array, either strings if the only difference is the name, or object array with whatever properties vary between the cosmosdb accounts, then use the for ... in sentence against it, find an example for multiple storage accounts here learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/…
    – dtriana
    CommentedFeb 27 at 21:40

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.