Wednesday, December 23, 2009

Running PowerShell in the Cloud (with Azure)

There's a PowerShell Azure sample application HERE.

Briefly, in Azure terminology, the sample provides:

  1. The code to create a ASP.NET web role, which acts as the Internet-accessible web page that provides a simple interface to type in PowerShell code.
  2. The sample also provides the code to create a PowerShell worker role, which is basically C# code creating a PowerShell runspace which takes the input from the ASP.NET interface.
  3. So once a PowerShell command is passed via the web interface, it is passed to the PowerShell runspace.  Once the PowerShell runspace finishes the command passed, it returns the results back to the ASP.NET page to display.

I built the project yesterday using Visual Studio 2010 Beta 2.  Here’s the resulting Azure application:  (This link may be removed early in 2010 once Azure becomes a paid service.)

Give the above link a try.  For example, try “get-service cl*”.

Assuming this is PowerShell version 2.0, it is a very restricted runspace, and some commands just won’t return any results…