pauldog90
pauldog90

Reputation: 21

How do I deploy multiple CosmosDB accounts with Databases/containers using ARM templates without nested loops?

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.

Upvotes: 0

Views: 22

Answers (0)

Related Questions