Windows Azure PowerShell - Script for basic PaaS and IaaS Operations

We assume that you have already set up your PowerShell for Windows Azure based on our previous Blog Post: Windows Azure PowerShell – Getting Started. In this blog we will be providing a Menu Based PowerShell Script to perform basic Cloud operation on Windows Azure.

Before we dive into the details, stack of possible operation that can be performed on Platform as a Service (PaaS) and Infrastructure as a Service (Iaas) differs based on type of execution Model.

Windows Azure provides Infrastructure as a Service (IaaS), web hosting, and Platform as a Service (PaaS).

Each of these three approaches-Virtual Machines, Web Sites, and Cloud Services-can be used separately. You can also combine them to create an application that uses two or more of these options together.

Source: https://www.windowsazure.com/en-us/develop/net/fundamentals/intro-to-windows-azure/#header-2

We have two purpose behind this script as:

  1. You can take this script and modify for your own purpose.
  2. Based on request and interest we will be adding few options on regular intervals or based on any future release.

Currently Windows Azure PowerShell Provide approximately 137.

This script also provide to use verbose output which allow user to see all Rest API call made to the service.

In February Release of Windows Azure PowerShell, Addition of Debugging Preference option allowing user to see request and response that take place with the execution of any Command.

 To enable debugging user need to specify  $DebugPreference value. 

------------------

Valid values:

Stop: Displays the debug message and stops executing. Writes an error to the console.

Inquire: Displays the debug message and asks you whether you want to continue.

Continue: Displays the debug message and continues with execution.

SilentlyContinue (Default): No effect. The debug message is not displayed and execution continues without interruption.

-----------------

Example:

 

PS C:\> $Debugpreference

SilentlyContinue

PS C:\> Get-AzureVM

 

ServiceName Name Status

----------- ---- ------

test test StoppedVM

 

PS C:\> $DebugPreference ='Continue'

PS C:\> $Debugpreference

Continue

PS C:\> Get-AzureVM

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:

GET

<…>

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:

OK

<…>

 

DEBUG: ============================ HTTP REQUEST ============================

 

HTTP Method:

GET

<…>

PS C:\ $debugpreference = "Inquire"

PS C:\ write-debug "Hello, World"

DEBUG: Hello, World

 

Confirm

Continue with this operation?

[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): A

----------------------------------

PS C:\ Get-AzureVm -Debug:$false

# Use the Debug parameter with $false

PS> # The debug message is not displayed and processing continues.

 

 

(Download Script - PowershellMenuPub.ps1 - At the bottom of the blog) – Last updated 02/17/2013 (You might need to do minor edits based on your subscription)

Many thanks to Avkash Chauhan for review and valuable inputs.

Keywords: Windows Azure PowerShell, Iaas, PaaS, Operation

 

Please let us know what you would like to see in future and how we can improve it.

 

--------------------

Abhishek Anand

Support Escalation Engineer

Windows Azure Technical Support