This is an interesting problem that comes with the territory (of JSON spec that is). We are hoping Microsoft will come with a solution for this in the future, but for the time being, the solution is a bit ghastly.
This problem manifests itself in places like, adding data disks based on VM size (in Azure, different VM sizes allow different maximum number of data disks that can be attached to them. Please see this article for details) or number of nics for clusters of different sizes. Unfortunately the solution here is to create clones of VM deployment templates for different VM sizes, each with hardcoded JSON arrays for disks, and reference them with the techniques described above.
Let’s go through the solution here. You will notice a set of variables that are complex objects, with the naming convention “tshirtSize*” which can be “tshirtSizeSmall” etc.
- You need to provide a tshirt size to the template when deploying, that can be “Small”, “Medium” and “Large”.
- This will set the value of the variable “clusterSpec” with “clusterSpec“: “[variables(concat(‘tshirtSize’, parameters(‘tshirtSize’)))]“
- The clusterSpec will contain the name of one of the “tshirtSize*” variables.
- In that variable, you will notice the vmTemplate property will be pointing to one of the templates clones