Getting Started With PowerShell On Windows Azure

There are over 700 PowerShell cmdlets to help you automate routine and complex tasks in Windows Azure. Here’s how you can start taking advantage of what PowerShell has to offer in Azure.

 

One of the most popular public cloud services is Microsoft Azure. Azure is an enormous infrastructure of servers in dozens of data center across the world. It provides many different services, which are primarily controlled by Microsoft’s Azure Portal. The Azure Portal is where all of the Azure services are managed, but it’s not the only place through which Azure resources can be managed. Another method is Windows PowerShell.

When managing Azure resources through PowerShell, an administrator can automate lots of routine and complex tasks that the Azure Portal cannot provide. In this article, we’ll go over how to get started using PowerShell with Windows Azure.

Installing the Azure PowerShell Module

Azure is controlled via a PowerShell module, which is provided by Microsoft. Your first task is to get this module installed. To do this, download and install the Microsoft Web Platform Installer packagefor the Azure module. This convenient installer will install the Azure PowerShell module and all of the prerequisites for you.

The installation will take just a few minutes. And once installed, you must then connect your Azure subscription.

Connecting Your Azure Subscription

After the Azure module is installed, open up your PowerShell console, and type Add-AzureAccount. This will bring up a small page asking you to input your account that has an active Azure subscription attached to it.

Input your credentials to attach your Azure subscription to the Azure PowerShell module. Once this happens, you’re ready to begin looking around to see what you can do.

The first thing I always recommend to anyone when exploring a new PowerShell module is to use the Get-Command cmdlet. By using this command, you can easily explore all of the cmdlets available to you in that module.

As of this writing, there are 716 cmdlets in the Azure module. You’ve got a lot of opportunity here!

Another cmdlet you should get familiar with is Get-Help. PowerShell has a great help system, and using it allows you to get up to speed quickly on everything the Azure module can do. To use PowerShell’s help, simply pass the name of the cmdlet you want to learn more about to the Get-Help cmdlet.

    Get-Help Get-AzureVMImage

This example retrieves all help topics about the Get-AzureVMImage cmdlet. Feel free to peruse the cmdlets available to you in the Azure module, and use Get-Help to dig a little deeper to unerstand their purpose.

The following is an example of using the Get-AzureVMImage cmdlet. This time, you will only see the images that have the word “Windows Server 2012” in them.

This is just a single example from a single cmdlet in the Azure PowerShell module. As mentioned, there are over 700 different cmdlets for provisioning network resources, creating new VMs, modifying storage settings, and much more.

By using the Azure PowerShell module, you can now quickly get information about your Azure subscription and resources, automate provisioning new services, and begin building some solid tools around Azure.