简体   繁体   中英

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)]"
  ],

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM