20 Key Scenarios with Windows Azure Infrastructure Services (IaaS): Quickly Provisioning Development / Test Environments with PowerShell

imageAs a lot of you know I am extremely passionate about PowerShell.  Fundamentally the language has been growing leaps and bounds over the years.  PowerShell should become the scripting tool of choice for you and your infrastructure.  Being able to leverage this fantastic language will save you time.  In addition PowerShell provides the key automation platform for you and your datacenter.  In many cases PowerShell is the under the covers workhorse that does all the chores given to it by the GUI interfaces.  In fact the new server manager in Windows Server 2012 is built on PowerShell.

Before I go any further with PowerShell I want to make sure you have a solid foundational knowledge on how to read the language.  To that end, I recommend if you have not taken the time to learn the language checkout the series I did in May 2011.  While the series is written for PowerShell version 2 (we are currently on version 3), it is still foundationally sound. You can find the series here:

PowerShell Not Your Father's Command Line: 31 Days of PowerShell 

With Windows Azure you can use PowerShell in two wonderful ways.  First, you can use PowerShell to work with the Windows Azure portal.  This allows you to do many things from provisioning Virtual machines, creating affinity groups, setting up virtual networks, creating endpoints, even help with the winning lottery numbers.  Okay so I am kidding on the last part.  The point being is you can leverage PowerShell to fully automate the provisioning and creation of Windows Azure Infrastructure Services.    Check out my teammate Yung’s wonderful post where he talks about using PowerShell this way.   Here is the article he wrote on using PowerShell for his environment: One-Click Windows Azure VM (IaaS) Deployment with PowerShell User Experience 

The second way you can leverage PowerShell is the same way you leverage PowerShell for your servers today.  Remember when you provision a server in Windows Azure it is a Windows Server like any other Windows Server.  When you connect to the server with the built-in RDP connection you have the same PowerShell abilities you would normally have on the server.  Which simply means, as my friend Ed Wilson puts it,

PowerShell is PowerShell is PowerShell.  

In addition to that, one of the many new enhancements Windows Azure portal provides is the ability to setup PowerShell remoting for your Windows Azure virtual machines.  When you create a virtual machine in Windows Azure you now have the option to enable PowerShell remoting:

image

When you select this option Windows Azure it will also provision the endpoint to enable the remoting:

image

To fully take advantage of this feature you will need to configure hybrid networking to Windows Azure either through the site to site to VPN or the point to site VPN (in preview).  Keith Mayer does a great job of explaining how to work with hybrid networking here: Guided Hands-on Lab: Extend Your Private Cloud with Windows Azure Virtual Networks and Windows Server 2012 [ 20 Key Scenarios with Windows Azure Infrastructure Services ]

If your looking to work directly with Windows Azure to provision your environment you will need to make sure you have your Windows Azure Trial, you can sign up here: https://aka.ms/getazureiaas Then you will need to get the PowerShell cmdlets located here:  Windows Azure PowerShell

Now I wish it was as simple as just getting the cmdlets and going.  However, since we are using Windows Azure there are a couple of things you will need to do first to make sure you connect to your Windows Azure environment.  Mainly you will need to configure your Windows Azure subscription settings, you can use the Set-AzureSubscription and Select-AzureSubscription cmdlets that are a part of the Windows Azure cmdlets.    You would need to set these with variables. 

The easier way is to leverage the publisher settings file. This provides an easy to use file that will configure your PowerShell session to use your specific Windows Azure subscription.  After you have downloaded the PowerShell cmdlets and configured your PowerShell security to RemoteSigned you will run the following cmdlet:

Get-AzurePublishSettingsFile

After you run the cmdlet you will be prompted to sign with your ID associated with Windows Azure.  After you have signed in your screen similar to this:

image

Then after you have downloaded the file you will then run the following cmdlet to configure your PowerShell session to work with your Windows Azure environment:

Import-AzurePublishSettingsFile <the mysettings file you downloaded >. publishsettings

Once you have the settings configured then you can proceed to begin to working with PowerShell.  Here are a couple of resources for you:

With all you can do with PowerShell the extension to Windows Azure is logical and powerful, get started today and make sure you sign up for your free trial: https://aka.ms/getazureiaas

Let us know what scenarios are you interested in seeing?  Are you currently using Windows Azure, if so how are you using it?  Let us know and email me mhester@microsoft.com or comment on this post.  We will try to include them in this series.

Also remember to sign up for your free Window Azure trial: Get Started TODAY with a FREE 90-DAY Windows Azure Subscription

You can find the full series here: 20 Key Scenarios with Windows Azure