Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)]"
  ],
like image 254
chew224 Avatar asked Sep 05 '26 08:09

chew224


2 Answers

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!

like image 53
4c74356b41 Avatar answered Sep 08 '26 07:09

4c74356b41


As of today, Azure has added support for the conditional dependsOn in Define the order for deploying resources in ARM templates

This allows for the exact feature you are looking for. That is to say: You can simply add all conditional dependencies in the depondsOn array. Those dependencies evaluated as false will be removed.

like image 24
JaydenLiang Avatar answered Sep 08 '26 07:09

JaydenLiang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!