Manage Windows Azure using PowerShell: Part 1 – “The Setup”

When companies start using Windows Azure it sooner or later comes to the situation that you want to use the same management tools to manage on premise VMs and apps and azure-based VMs and apps. No big deal: Microsoft delivers a PowerShell module for managing Windows Azure! Together with other cool things like the Azure integration in SCOM, the Azure SCORCH integration pack etc. you get a great toolset for managing hybrid infrastructures. In this article I will demonstrate the steps that are needed to bring the PowerShell module for Windows Azure to life.

Before we can use Azure PowerShell cmdlets we need to create a Windows Azure management certificate and assign it to an Azure subscription. There are multiple ways to do that, I will demonstrate how to create a self signed certificate using makecert.exe.

-sk “name” —> Subject key container name
-pe –> Marks private key as exportable
-ss “my” –> Certificate store used to sace the certificates/keys
-n “cn=name” –> Subject name


Once the certificate is created and stored in the defined container, we need to export the certificate to a file. Start mmc.exe and add the certificates snap-in. Choose the correct area from where certificates should be displayed. In this example I stored the certificate in the user personal store and therefore select “My User Account”. The certificate should be visible under “”Personal\Certificates” and can now be exported.


We only need the certificate, not the private key. This key needs to be stored in a safe place and will be used later when we connect to Windows Azure using PowerShell.



Select a path and file name to save the certificate.


The next step uploads this certificate to Windows Azure management certificates store. You can see those certificates using the Windows Azure management web site.


Now start the upload wizard and enter the path to the exported management certificate.


Done! Now you can download and install the Windows Azure PowerShell module from here. Now start the PowerShell module (by using the search term “PowerShell” or something). Use the cmdlet “Get-AzurePublishSettingsFile” to get the settings file from your Azure subscription that holds all the connection details. A Browser will automatically start and you need to login to Windows Azure. Save the file that automatically gets downloaded on your computer.

Depending on the system configuration you may need to change the execution policy by using the command “Set-ExecutionPolicy remotesigned”


Once the file is saved, import it using the cmdlet “Import-AzurePublishSettingsFile”.


Done! You can now start using the Azure PowerShell module. As a quick example I demonstrate how Azure VMs can be started.

– There are 2 stopped VMs


– Get all Azure VMs and start them (Get-AzureVM, Start-AzureVM)


– Check the result, VMs are starting/started


With that up and running you can now start manage your Azure VMs, applications etc. the same way as your on premise stuff. Pretty cool!

In the next post I will demonstrate some handy script to manage your Azure subscription, VMs etc. So make sure you don’t miss that!


About Marcel Zehner

Microsoft Azure MVP
This entry was posted in Azure and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s