Following on from this question, I need to go a step further and be able to create multiple data disks of different sizes, where quantity and sizes are specified at deploy-time.
My latest incarnation is creating the (managed) disks in their own resource outside the VM resource and then trying to attach them.
It seems that the copyindex resets for each resource so I believe I need to create them all in one copy so the "attach" part in the VM resource can use the length function, but I cannot think of a way to change any property inside the copy loop when a certain iteration is reached (I would understand why this isn't possible).
I'm thinking I need to use something like:
"count": "[variables('numberOfDisks')[parameters('DiskSize')]]"
But unsure how to proceed.
I've also thought about nested templates, but again, this falls foul of not being able to change parameters inside a loop.
In programming, I could create a 2d array or dictionary object, but cannot find a way to do this in ARM templates, although, I have just found Intersection.
Datadisk configuration examples: It is only the size and quantity that vary per deployment. All other properties are anticipated to be the same for all disks for any given VM.
- VM 1: 2x @ 256GB, 4x @ 512GB, 4x @ 1023GB
- VM 2: 1x @ 1023GB, 1x @ 80GB
- VM 3: 1x @ 1023GB, 1x @ 80GB, 2x @ 256GB, 2x @ 512GB
My template only deploys one VM, but the number and size of disks are unknown. The idea as that DSC will come along and create volumes, collating the disks based on their size.
I'm not going to paste my workings as they are long, wrong and bulk out this post. Hopefully the above is enough to prove I have been trying to work things out for myself.