To create new VMs for use with the Virtual Machines and Virtual Networks preview feature for Azure, you can use the Azure PowerShell Commands available at https://www.windowsazure.com/en-us/downloads/. The specific commands to provision a VM are…
- New-AzureVMConfig – http://msdn.microsoft.com/en-us/library/windowsazure/jj152883.aspx
- Add-AzureProvisioningConfig – http://msdn.microsoft.com/en-us/library/windowsazure/jj152870.aspx
- New-AzureVM – http://msdn.microsoft.com/en-us/library/windowsazure/jj152815.aspx
The examples on how to use this are typically as follows:
This is fine when deploying creating one Virtual Machine, however this can be slightly unreliable when you need to create multiple VMs in quick succession. I would often see that the VM I created was stopped, and the following error was shown:
“The server encountered an internal error. Please retry the request. The long running operation tracking ID was: [UNIQUEID]”.
To avoid errors, you can use the above commands in a different way to that specified in the examples, creating multiple configs, but only calling New-AzureVM once (passing it an array of configs), as well as giving the deployment a unique name. The example below illustrates this…
Note, there is also some documentation of this available at http://msdn.microsoft.com/en-us/library/windowsazure/jj835085.aspx (see the section on “Creating Multiple Virtual Machines”.
Written by Rob Nowik