kumar
kumar

Reputation: 9407

Azure create 40VM in parallel using ARM template

I need to create 40VMs from an image connected to a single loadbalancer using ARM template. Is there a way to specify the count for the number of VM resource?

I am not looking for scale-set solution.

Upvotes: 0

Views: 92

Answers (1)

Nancy Xiong
Nancy Xiong

Reputation: 28264

You can use copyIndex function as copyIndex(loopName, offset).

The following example shows a copy loop and the index value included in the name.

{
      "apiVersion": "2018-04-01",
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[concat(parameters('vmNamePrefix'), copyindex())]",
      "copy": {
        "name": "virtualMachineLoop",
        "count": "[variables('numberOfInstances')]"
      },

For example, you can change the variables('numberOfInstances') to 40, and note that such resources like Azure VM name, osProfile, networkInterfaces should have unique name(include copyIndex()) in the following reference templates.

https://github.com/Azure/azure-quickstart-templates/tree/master/201-2-vms-loadbalancer-lbrules

https://github.com/Azure/azure-quickstart-templates/tree/master/201-2-vms-internal-load-balancer

Upvotes: 1

Related Questions