Cloud Computing

Use PowerShell to Create a New Virtual Machine in Windows Azure Running Server 2012 R2

In this Ask the Admin, I’ll show you how to connect to your Azure subscription using PowerShell and create a new virtual machine (VM) using the New-AzureQuickVM command.

Before you can use PowerShell to remotely manage Windows Azure, you will need to set up remote PowerShell management for Windows Azure.

Let’s start by setting the Azure subscription in PowerShell. Open a PowerShell prompt with elevated privileges:

  • In the PowerShell console, type Get-AzureSubscription, and make a note of the SubscriptionName in the output. In my case, Pay-As-You-Go.
  • Type Get-AzureStorageAccount, and make a note of Label in the output. My storage account is labelled portalvhdsxgwgzn2ml54p5.
  • Now set the Azure subscription in PowerShell as follows using the SubscriptionName and Label parameters from the commands above: Set-AzureSubscription “Pay-As-You-Go” -CurrentStorageAccount portalvhdsxgwgzn2ml54p5

Now that the subscription is set, chose an image from the gallery to use as the basis for the new VM.

Sponsored Content

Passwords Haven’t Disappeared Yet

123456. Qwerty. Iloveyou. No, these are not exercises for people who are brand new to typing. Shockingly, they are among the most common passwords that end users choose in 2021. Research has found that the average business user must manually type out, or copy/paste, the credentials to 154 websites per month. We repeatedly got one question that surprised us: “Why would I ever trust a third party with control of my network?

  • Type Get-AzureVMImage to get a list of the available images. I’m going to use the latest image of Windows Server 2012 R2 for my VM, and the Image name is a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201311.01-en.us-127GB.vhd

Finally, create the VM. Run the command shown below, replacing the –AdminUsername and –Password parameters with any username and password that you choose. The –ServiceName and –Name parameters can be the same.

Each VM should run in its own cloud service, unless you plan to load balance one or more VMs. You might need to experiment with the –ServiceName parameter to successfully create a new VM, as it should be globally unique. It’s often the case that you will specify an already existing cloud service name.

The –location parameter can be set to East Asia, Southeast Asia, North Europe, West Europe, Central US, East US, East US 2, or West US.
https://petri.com/create-virtual-machine-in-windows-azure-powershell New-AzureQuickVM -Windows -ServiceName mysrv1 -Name mysrv1 -ImageName a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201311.01-en.us-127GB.vhd -AdminUsername mysrv1admin –Password ********* -location “North Europe”
A new VM being provisioned in Windows Azure

If you look in the Azure management portal window under virtual machines, you should now see an entry for the new VM. It can take up to five minutes for the provisioning process to complete.

Related Topics:

BECOME A PETRI MEMBER:

Don't have a login but want to join the conversation? Sign up for a Petri Account

Register
Comments (1)

One response to “Use PowerShell to Create a New Virtual Machine in Windows Azure Running Server 2012 R2”

  1. […] At the time of writing this article, the only way to ensure that a VM receives a persistent IP address every time it is started from a virtual network is to create the VM using PowerShell. Before you can use PowerShell to remotely manage Windows Azure, you will need to set up remote management on a computer on your local network. For more details on how to set up remote management, see my Ask the Admin article here. […]

Leave a Reply

IT consultant, Contributing Editor @PetriFeed, and trainer @Pluralsight. All about Microsoft, Office 365, Azure, and Windows Server.
Don't leave your business open to attack! Come learn how to protect your AD in this FREE masterclass!REGISTER NOW - Thursday, December 2, 2021 @ 1 pm ET

Active Directory (AD) is leveraged by over 90% of enterprises worldwide as the authentication and authorization hub of their IT infrastructure—but its inherent complexity leaves it prone to misconfigurations that can allow attackers to slip into your network and wreak havoc. 

Join this session with Microsoft MVP and MCT Sander Berkouwer, who will explore:

  • Whether you should upgrade your domain controllers to Windows Server
    2019 and beyond
  • Achieving mission impossible: updating DCs within 48 hours
  • How to disable legacy protocols and outdated compatibility options in
    Active Directory

Sponsored by: