Azure ARM Templates Tips and Tricks 3: Use complex objects to group related values together

As a natural consequence of nested templates, you will see passing parameter values down the line to the other templates is inevitable. So, instead of passing the related values as separate parameters, group them in a complex object once and pass them using the complex object. Example from the azuredeploy.json template, variables section:

And its usage as:

Abuse JSON spec for including comments

The template language does not allow comments, but you may want to add comments for your templates. Just add properties and values as you see fit. The template processor will ignore them (for now, and this may be potentially unsafe).

In this example, notice “vmSize” and “maxNumberOfDataDisksForVmSizeNotUsedButHereForReference” properties.

NOTE: Grouping parameters into complex objects may have side-effects, such that a JSON-serialized representation of the complex object can be accessible through the portal. It will in turn unexpectedly expose sensitive template parameters such as passwords. Therefore, this technique is not recommended if any of the properties of a complex object are secure strings.

 Next tip