Search code examples
jsonazureazure-rm-template

Azure ARM Template: DependsOn conditional statement


Does anyone know if there is a way to put an inline conditional statement inside the dependsOn element? I want to put a condition in that the resource will deploy on if either nestedTemplateA exists already OR if nestedTemplateB exists already.

Any help is appreciated!

  "dependsOn": [
    "[or(nestedTemplateA, nestedTemplateB)]"
  ],

Solution

  • ok, first of all, you can depend on existence of something (strictly speaking), you can only depend on resource being created successfully in the same (!!) template. so if your template has this structure:

    resource1 - nested template
    resource2 - nested template
    resource3 - the one you are asking about
    

    you just need to use this as dependsOn:

    "dependsOn": [
        "resource1",
        "resource2"
    ]
    

    but, as your question reads: "resource will deploy on if either nestedTemplateA exists already OR if nestedTemplateB exists already." its really hard for me to be sure I'm answering the right question. if this is not what you are asking about, can you please comment on this answer if you need more help (and, perhaps, rephrase your question). I'll edit this answer, cheers!