Search code examples
azureroutesazure-rm-template

Nested Copy on Azure ARM template


What I need to do is: Create routing rules for each of my routes (http) assigned with just 2 frontends Create one more routing rule, but with all available frontends assigned to it.

Currently I am using the copy like this

    copy[
"name": "routingRules",
                        "count": mylengthvariable,
                        "input": {
                            "name": mynamearraywithsomeconcats,
                            "properties": {
                                "frontendEndpoints": the frontendpoint for this rule,
                                etc.. etcc
                                    }
                                }
                            }
                        }
]

this is all well and good but I need to add yet another routing rule, but with more frontendpoints; which would like this: (this is placed outside of the copy above)

 "name": "routingRules",
                        "input": {
                            "name": "extrarule",
                            "properties": {
                                "copy":[
                                    {
                                        "name" : "frontEndpoints",
                                        "count": frontendpointcount,  
                                        "input" : {
                                         "id": a list of frontendpoints
                                        }         
                                    }                                   
                                ],
                               etc.. etc..
                                
                                
                            }
                        },

When I try this, I get the error because I am trying to add one more rule (I think)

I am seeking help on how to implement such a scenario. Thanks in advance.


Solution

  • It is not possible to perform nested copies in ARM templates (unfortunately). There are some workarounds you can perform, such as expanding the sub-item in a variable, then referencing the variable.

    Details and examples can be found here: https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/copy-resources