<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1678611822423757&amp;ev=PageView&amp;noscript=1">
Defrag This

| Read. Reflect. Reboot.

Getting Started with Microsoft Azure's Cloud Shell

Adam Bertram| May 16 2018

| IT insights

getting-started-with-microsoft-azures-cloud-shell

When you need to get access to a command line console like PowerShell or Bash, where do you go? 

 

Chances are, if you're on Windows, you fire up the PowerShell executable, or nowadays even Bash on Windows. Likewise, if you're on MacOS or Linux, you can bring up both consoles as well. But what if you didn't have to worry about the OS you're on at all or even if you're on your iPhone to get to CLI (command-line interface)? It's possible with Azure Cloud Shell.

Azure Cloud Shell is a service from Microsoft that allows you to have a PowerShell or Bash console right from within your browser. Because it's browser-based, you don't have to worry about having any local setup to run PowerShell or Bash. Azure Cloud Shell is truly what the cloud was created for. No need to worry about any of the underlying infrastructure if all you need is a console.

Learn how to automate IT tasks with PowerShell. Download this eBook. 

To use Azure Cloud Shell, you'll need to have an Azure subscription and depending on what resources you use while logged in you may be charged. When you first sign up, you'll need to have a resource group, storage account and Azure File Share associated with it.

azure-cloud-shell-1

You'll need to have these resources to use the service because it needs a place to store some temporary information for your sessions. This is only a one-time setup and once setup, it will use the file share for all subsequent sessions.

You can have Azure Cloud Shell create all of these resources for you, but if you'd rather create them yourself, there's an advanced option you can use to define everything the way you'd like.

azure-cloud-shell-2

When you get the storage setup, depending on the shell you choose, you'll be dropped into either Bash or PowerShell. If using Bash, you'll be dropped into the console with the Azure CLI immediately available.

azure-cloud-shell-3

If using PowerShell, it will drop you onto a Windows Server 2016 VM in the background where you have Windows PowerShell available. Notice from the screenshot above that you'll have the Azure PowerShell modules already available. When you first start it up, you'll be in the Azure drive. This allows you to browse all of your Azure resources just like a file system.

If using PowerShell, another cool feature of the Azure Cloud Shell is the ability to enter your Azure VMs with the Enter-AzureRmVm and Invoke-AzureRmVmCommand commands. These commands are built on top of PowerShell remoting and allow you to seamlessly run PowerShell remoting commands directly to any of your Azure VMs without having to worry about configuration or authenticating across the Internet. While you're in the Azure Cloud Shell, you've already authenticated and can then easily run whatever commands you'd like on any of your Azure VMs.

The VMs that Azure Cloud Shell runs on also come with various tools pre-installed such as the Azure CLI, various package managers, Git, Pester, and so on. If a tool you need doesn't exist, you can always download it via Install-Module if on PowerShell or via the package manager of your choice if running Bash.

The one caveat I've found annoying with the Azure Cloud Shell is that it has a 20-minute timeout. If you're like me, you've got a task to do in PowerShell and then get busy doing something else. You switch contexts and begin working on something else to then come back around to your session and continue on that task. If you're in the Cloud Shell and 20 minutes has passed, you'll have to start another session. If using PowerShell, this can take a minute or two which is a major inconvenience.

I've also seen that when copying and pasting multiple lines into the console, it will paste them in the wrong order. This appears to be a bug which I hope can be fixed at some time. Overall though, for a service that's as new as the Cloud Shell, it's proven super-useful and is my go-to resource when I just need a quick PowerShell or Bash prompt.

Topics: IT insights

Leave a Reply

Your email address will not be published. Required fields are marked *

THIS POST WAS WRITTEN BY Adam Bertram

Adam Bertram is a 20-year veteran of IT. He’s currently an automation engineer, blogger, independent consultant, freelance writer, author, and trainer. Adam focuses on DevOps, system management, and automation technologies as well as various cloud platforms. He is a Microsoft Cloud and Datacenter Management MVP and efficiency nerd that enjoys teaching others a better way to leverage automation.

Free Trials

Getting started has never been easier. Download a trial today.

Download Free Trials

Contact Us

Let us know how we can help you. Focus on what matters. 

Send us a note

Subscribe to our Blog

Let’s stay in touch! Register to receive our blog updates.