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
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
Login into Azure Portal (portal.azure.com)
Near top right, click on
Dedicated Cloud Shell site: https://shell.azure.com/powershell
Login into Azure Mobile App
- Takes at least a minute to start up a terminal session
- Idle session disconnects in about 20 mins.
- Embedded in the browser, so can run Azure PowerShell on any device with a web browser.
- Run in native mobile app.
Managing within a subscription
If you are like me, I have a handful of subscriptions where I need to switch between with ease.
Set-AzureRmContext –SubscriptionId <id> cmdlet
At Azure: root, simply list subscriptions and cd .\<subscription name>
⦁ Very easy to move between subscriptions.
Simply save PowerShell script files onto your local computer (e.g. Save As)
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.I also use the Azure Portal
- Central file storage of scripts that can be accessible from cloud shell and even mapping the file share to your local computer.
- Cumbersome to save and manage files through a mounted file share.
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.
Fully featured editors with such as file tabs, multiline editor, debugger and break points and running selected lines with:
- Installed by default in any windows environment
Visual Studio Code
- add the PowerShell extension:
Use editors such as vim and nano.
Example of vim
Edit getVMStatus.ps1 file
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.
- Overview of Azure PowerShell
- Quickstart for PowerShell in Azure Cloud Shell (Preview)
- Features & tools for PowerShell in Azure Cloud Shell (Preview)
- Managing your resources with Azure Cloud Shell
- Limitations of Azure Cloud Shell
- Persist files in Azure Cloud Shell