Stop and deallocate an Azure VM from Release Management

Problem:

While trying to start an Azure VM from Release Management I get the following error:

"ERROR: Windows Azure PowerShell Cmdlets is not installed."

Even though I followed all of the instructions here.

Solution:

There are actually two solutions.  First is update the "PSModulePath" environment variable by removing the "Azure\" from the "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\" portion.  It appears that the ControlAzureVM.ps1 file that ships with Release Management Update 2 RC appends the "Azure\" itself. If it is already in the path it will fail.  I am not sure if the latest Azure SDK has change this value or not.

I decided not to modify the environment variable for fear that it might break other parts of the Azure SDK.  So I took this opportunity to write my own ControlAzureVM.ps1 file that honors the environment variable as it is set by the SDK.  I also decided to enhance the script to not only support Start and Stop but to also support Shutdown of a VM.  Stopping a VM will place it in the Stopped state.  Unfortunately this means you are still being charged compute hours for that VM.  Only Azure VMs in the Stopped (Deallocated) state are free.  Therefore, I added a new Action for Shutdown that will deallocate your VM as well.  You can download the PowerShell file below.

Simply add the PowerShell script as a new tool.  Copy all of the values for the settings from the out of the box Azure tool.

Then added three new Actions. One for Start, Stop and Shutdown using the new tool. Noticed the "ACTION" place holder of the tool is replaced in each action.

ControlAzureVM.ps1 (6.05 kb)

Comments are closed