VM creation using ARM template

sns 9,226 Reputation points
2022-12-21T15:38:11.39+00:00

I have tried to create VM and in the end I have cancelled VM creation, instead I have downloaded ARM template which is there beside create button. ( VM name is VM1) 272981-template.txt272982-parameters.txt

Now I have downloaded ARM template. I have attached template and parameters file.

Please help me in what are the values/changes to be done to these templates and where exactly it need to be done to create 5 VMs ( VM2, Vm3, VM4, VM5 and VM6) from this existing template. Thank you.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,157 questions
0 comments No comments
{count} votes

Accepted answer
  1. KarishmaTiwari-MSFT 18,522 Reputation points Microsoft Employee
    2022-12-28T01:11:47.017+00:00

    Hi @sns , Thanks for posting your query on Microsoft Q&A.

    This article shows you how to create more than one instance of a resource in your Azure Resource Manager template (ARM template). By adding copy loop to the resources section of your template, you can dynamically set the number of resources to deploy. You also avoid having to repeat template syntax.

    Add the copy element to the resources section of your template to deploy multiple instances of the resource. The copy element has the following general format:

    "copy": {  
      "name": "vmcopy",  
      "count": 5,  
      "mode": "serial" <or> "parallel",  
    }  
    

    The name property is any value that identifies the loop. The count property specifies the number of iterations you want for the resource type.

    You will also need to make changes to the parameters file for each of the parameters in the template like imageSKU, vmsize, location etc.
    Once you have the template and parameter files for each VM, you can deploy the template using Azure CLI (az deployment group create) or PowerShell (using New-AzResourceGroupDeployment) to create the VMs.

    Here is a good example with all the details provided which will help make modifications for your scenario : https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/copy-resources#resource-iteration

    However, if you have any questions specific to VM deployment, let me know in the comments and I would be happy to help.

    0 comments No comments

0 additional answers

Sort by: Most helpful