0

I am able to create Azure VM using powershell.

I have to create 4 VM's parallel.

Does any feature in powershell to do create multiple VMs parallel ? Something like background jobs or call the same function for all different VMs using threads kind of ?

3 Answers 3

1

Have you considered VM Scale Sets? They automatically deploy VMs in parallel in a highly available configuration and make managing those VMs much easier (overview doc here: https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-overview). You can of course deploy a scale set or a bunch of VMs from powershell (doc for deploying a scale set via powershell here: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/tutorial-create-vmss), but the Powershell commandlets require you to specify lots of related properties (e.g. virtual network, subnet, load balancer configs, etc.). The Azure CLI 2.0 (which you can use on both Windows and Linux!) gives lots of good defaults. For instance, in Azure CLI 2.0 you can do this single command to create all of your VMs in parallel:

az vmss create --resource-group vmss-test-1 --name MyScaleSet --image UbuntuLTS --authentication-type password --admin-username azureuser --admin-password P@ssw0rd! --instance-count 4

(taken from the documentation here: https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-create#create-from-azure-cli)

Hope this helps! :)

Sign up to request clarification or add additional context in comments.

2 Comments

Hello Neil, can I create a scale set and still connect to each machine from outside, so far I have only one public IP?
The command above also creates a load balancer on the scale set with a public IP. So you should be able to RDP or ssh into the scale set VMs by using ports 50000 and above on the LB (e.g. you could RDP/ssh on <pip>:50000 to get to VM 0, <pip>:50001 to get to VM 1, etc.). If you want, you can create a public IP per VM with the --public-ip-per-vm option :)
0

No, there is no built-in Azure powershell cmdlets or features enabling you to do so. You can create your own routine for that. I'm using PS jobs for that.

You need to use Save-AzureRmContext and Import-AzureRmContext to authenticate powershell inside jobs or use any form of automated login.

Comments

0

Thanks all, I have solved my issue using PS workflow parallel and sequence features. Achieved it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.