Search code examples
azureazure-devopsazure-resource-managerazure-rm-template

Multiple Vms Arm template with different Vm names,sizes and same custom


I have seen many templates to create multi vms as loop using copy function. Ex: vm1, vm2 etc. But this is not how we put in practice as each vm has different function and the naming convention doesn't help. I am trying to create a template with different vM names, sizes and a single custom Image. Can anyone please help?


Solution

  • By using parameters, we can differentiate the VM names, sizes etc:

    "parameters": {
        "org": {
        "type": "array",
        "defaultValue": [
            "contoso",
            "fabrikam",
            "coho"
            ]
        }
    },
    

    <![endif]-->

    As Copy functions can get the correct value from parameter array and can set the count with length() automatically.

    Refer to MS Docs to understand more.

    Also have a look on this answer, thanks to SamaraSoucy for explanation.