Azure ARM Templates Tips and Tricks 1: ARM Template Language is declarative, but I want to branch on a parameter

Remember, we are in JSON and JavaScript territory. It does not mean we have full access to JavaScript features, but it also gives us some flexibility. You know, if you have a complex JavaScript object, you can access its properties through two different accessors, either through dot, or bracket notations. Example, if the object is defined as:

Using this trick, we use the “jumpbox” parameter that takes “enabled” and “disabled” values and construct the uri for the child jumpbox template based on the passed variable as in the snipet below:

So, based on the value of the parameter, “jumpbox” the uri becomes either

  • “https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/couchbase-on-ubuntu/jumpbox-resources-enbabled.json”

or

  • “https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/couchbase-on-ubuntu/jumpbox-resources-disabled.json”

and pulls in the required template.

There are multiple usages of this same technique, such as the tshirt sizes, or the “storageAccountSuffixForNode*” variables.

Next tip