Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
The Imperfect Lab: Deploying VMs
# Set Your Subscription and Storage Account
Set-AzureSubscription -SubscriptionName "Visual Studio Ultimate with MSDN" -CurrentStorageAccount "imperfectstore"
# Set basic variables for your VM. In this case, this is the adminstrator name and password, as well as the name of the Windows Server 2012 R2 image available at the time of this exercise. You'll want to make sure to get the current name of whatever OS you want to install.
$un = "adminname"
$pwd = "secretpassword"
$image = ""
# Pick up that VM image the full list with:
Get-AzureVMImage | Select ImageName
# Configure a few more variables using the New-AzureVMConfig. In this case, I'm settting the server name and instance size, pulling in the username and password variable I set with the lines above and specifying the pre-existing subnet I want to use.
$newVM = New-AzureVMConfig -Name "Server2" -InstanceSize "Small" -Image $image
| Add-AzureProvisioningConfig -Windows -AdminUserName $un -Password $pwd
| Set-AzureSubnet -SubnetNames "FirstSubnet"
# Finally, kick off the VM creation with one of the following options:
# Into an Existing Cloud Service:
New-AzureVM -VMs $newVM -ServiceName "imperfectcore"
# Into an New Cloud Service:
New-AzureVM -VMs $newVM -ServiceName "newcloudservice" -Location "West US" -VNetName "imperfectnet"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment