Comparing Cloud Shell with PowerShell Editors

I love using Azure PowerShell to script creating and managing Azure resources.

Yet there are two options I like to compare
1) A script editor such as Windows PowerShell ISE or Visual Studio Code;
2) Azure Portal’s Browser-based Cloud Shell

This post will be based on Windows environments, as opposed to mac and Linux based scenarios and cross-platform approaches.

Let’s look at the following comparisons

Starting Point and Login

The experience in starting up and logging into a session

Script Editor:
Open any PowerShell supporting editors such as PowerShell ISE or VS Code with the PowerShell Extensions
Prerequisite: Install-Module AzureRM
Login-AzureRmAccount and enter your credentials into the popup dialog

Cloud Shell:
Login into Azure Portal (portal.azure.com)
Near top right, click onComparing Cloud Shell with PowerShell Editors 1

Dedicated Cloud Shell site: https://shell.azure.com/powershell
Login into Azure Mobile App

Disadvantages

  • Takes at least a minute to start up a terminal session
    Comparing Cloud Shell with PowerShell Editors 2
  • Idle session disconnects in about 20 mins.

Advantages

  • Embedded in the browser, so can run Azure PowerShell on any device with a web browser.
  • Run in native mobile app.  Comparing Cloud Shell with PowerShell Editors 3

Managing within a subscription

If you are like me, I have a handful of subscriptions where I need to switch between with ease.

Script Editor:
Set-AzureRmContext –SubscriptionId <id> cmdlet

Cloud Shell:
At Azure: root, simply list subscriptions and cd .\<subscription name>

Comparing Cloud Shell with PowerShell Editors 4

Advantages:

⦁ Very easy to move between subscriptions.

File Storage

Script Editor:
Simply save PowerShell script files onto your local computer (e.g. Save As)

Cloud Shell:
Cloud Drive located at C:\users\ContainerAdministrator\CloudDrive or $home\clouddrive
Save and execute PowerShell script files in this location
Move between Azure Drive and cloud drive via cd azure: and cd c: respectively

To upload and download from the cloud drive, I use the storage explorer desktop client and connect to the File Share representing the cloud drive.Comparing Cloud Shell with PowerShell Editors 5I also use the Azure Portal Comparing Cloud Shell with PowerShell Editors 6

Advantages

  • Central file storage of scripts that can be accessible from cloud shell and even mapping the file share to your local computer.

Disadvantages

  • Cumbersome to save and manage files through a mounted file share.

Script Editing

For my own day to day scripting, I feel there are two broad use cases

  • Script editing for large, modular scripts. Infrastructure as code situations
  • General management and browsing with a few lines of commands.

Script Editor:
Fully featured editors with such as file tabs, multiline editor, debugger and break points and running selected lines with:

PowerShell ISE

  • Installed by default in any windows environment

Visual Studio Code

  • add the PowerShell extension:

Comparing Cloud Shell with PowerShell Editors 7

Cloud Shell:
Use editors such as vim and nano.

Example of vimComparing Cloud Shell with PowerShell Editors 8

Edit getVMStatus.ps1 file

Comparing Cloud Shell with PowerShell Editors 9

Final Remarks

I find the sweet spot with Cloud Shell is portability. If you need an easy way to manage Azure resources when you are mobile and without your scripting environment on your computer, then you can use cloud shell in any supported browser or Azure mobile app. Useful scripts can be saved in your cloud drive and executed. So, when you get an email and you are waiting in line at the mall, you can literally execute your scripts that manages a bunch of services and get your job done.

References

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s