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

Getting Started with Microsoft Azure's Cloud Shell

Getting Started with Microsoft Azure's 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.

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.

azure-cloud-shell-4Notice 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.

Related Posts


Comments
Comments are disabled in preview mode.
Loading animation