Connecting Azure PowerShell to your Azure Subscription

** This process has changed, keep a look out of an updated article! **

Azure is becoming an ever more powerful cloud solution, with new services and improvements added almost on a daily basis. Microsoft Azure Management Portal offers the ability to manage many of these services, however the only way for administrators to make use of its full potential is by utilising PowerShell. Currently deploying multi NIC virtual machines is an example where PowerShell can achieve more than the normal portal.

Setting up your environment to enable remote management is achieved with two steps:

  1. Installing the Microsoft Azure PowerShell module on your client machine
  2. Connecting to your Microsoft Azure Subscription

When connecting to Microsoft Azure, administrator have two methods available to them.

  • Azure AD – This is generally the recommended authentication method since it makes it easier to manage access to the subscription.
  • Certificate Method – This is quickest and easiest to setup, good for testing with your own subscription. However its only valid as long as the subscription and certificate are valid for and makes it harder to manage access to a shared subscription.

The following section of this post will step through the installation of the Microsoft Azure PowerShell module and connecting in to an Azure subscription using the certificate method.

Installing the Microsoft Azure PowerShell Module

The first requirement to managing Microsoft Azure with PowerShell is to download and install the Azure PowerShell module. The simplest way to do this is run the Microsoft Web Platform Installer and step through the installation wizard.

ABPS001

ABPS002

Connecting to your subscription

Once the Microsoft Azure PowerShell module has been installed, the next step is to connect it to your Azure subscription. To do this we need to download the subscription information that contains the management certificate needed to connect PowerShell to your subscription. The Microsoft Azure PowerShell module includes cmdlets to allow you to download and import the certificate.

The first step is to open the Microsoft Azure PowerShell command window.

ABPS003

The next step is to use the following cmdlet to download your publishing profile.

Get-AzurePublishSettingsFile

ABPS0051

This cmdlet opens a webpage on the Microsoft Azure Management Portal and its from here you can select and download your publishing profile. The publishing profile is in the form of a .publishsettings file.

ABPS004

ABPS005

Once you have downloaded your publishing file, the next step is to import the information into PowerShell. To do this run the following command replacing the location of the downloaded file.

Import-AzurePublishSettingsFile C:\Downloads\TechKB.onl-3-23-2015-credentials.publishsettings

ABPS006

Once your publishing information has been imported, you should be connected to your Azure subscription. We can now use PowerShell to check subscription details. The following cmdlet displays the connected subscription ID, subscription name and other subscription details that make it possible to test that we are connected to the correct subscription.

Get-AzureSubscription

ABPS010

Its as simple at that!

Check out future posts to see how to deploy basic virtual machines in Azure using PowerShell.

Leave a Reply

Your email address will not be published. Required fields are marked *