Deploying thousands of VMs in VM Scale Sets (*quickly)

I recently worked with a customer who wanted to deploy thousands of the same VM to run various build(s) and test(s). They wanted to do this quickly, to make sure the engineers had results ASAP. To do some tests beforehand I came up with this little script, that takes a config file and other parameters and deploys a numbers of VMs in Scale Sets from a VM template.

Each line in the config file file looks like this:

MyVmss1 100 Win2016Datacenter Standard_D2s_v3

Values are seperated by spaces, the values are: Name Count Image Size IPs

I found that creating the VNet as part of the Scale Set create command was around 30 seconds faster per Scale Set.

The script also has 3 parameters useful for running it in parallel

$1 Inputfile – path to the input file to use

$2 Location – AZ region to use (use az account list-locations to get all locations)

$3 RGName – Name of the Resource Group to use

To run the script in parallel, just use multiple terminal sessions at the same time with different input files.