The Azure Cloud Shell

Learn about the Azure Cloud Shell in this lesson.

Azure gives you many different ways to interact with its resources from the Azure Portal, Azure SDKs, the command-line, and more. In this course, we’re going to focus on the command-line.

Even though you could manage Azure purely from a graphical user interface (GUI) perspective, this defeats a big DevOps pillar: automation. Even if you’re not automating tasks now, using the command-line will set you up for scripting and automation down the line.

PowerShell vs. Azure CLI

n this course, we’re going to focus on two command-line tools to manage and automate Azure: the Azure CLI and PowerShell. Why? Because the Azure CLI is an extremely common way to work with Azure across platforms (Windows and Linux), and many admins already know PowerShell. Both tools work well to manage Azure from the command-line, but they each have their nuanced differences.

Both tools have a lot in common and can generally perform the same tasks. They can even be used together. Each tool has its own way of working with Azure. But for the authors, it really comes down to two questions.

  • Are you managing Azure on an ad-hoc basis by opening a terminal, issuing commands, and answering interactive prompts?
  • Are you automating a process that requires running many different commands at once with a script?

Sure, there are other differences between the two tools, and both can interactively manage resources and build scripts around. But it makes intuitive sense to classify a scripting language as something better at scripting than a CLI tool.

The Azure Cloud Shell

Before we get too far into the PowerShell vs. Azure CLI debate, let’s first learn about a handy Azure service called Cloud Shell. Azure Cloud Shell is an Azure service that provides a command-line interface in your browser. The Cloud Shell gives you command-line access to both a PowerShell and Bash environment.

In Cloud Shell, you can just as easily manage Azure resources with PowerShell, Bash, or the Azure CLI since it comes installed automatically. There’s no need to install any prerequisites regardless of the OS you’re coming from.

The Cloud Shell provides a command-line experience by spinning up a temporary host and reading profile information from a required storage account. Unlike a local environment, the Cloud Shell does timeout after 20 minutes, which can be frustrating.

We’ll be using the Cloud Shell in this chapter to demonstrate managing Azure with PowerShell and the Azure CLI. If you plan on following along with the examples, project, and all screenshots to match exactly what you see, you will need to use the Cloud Shell, which we will provide you in a pre-configured environment on our platform.

Note: You can still use your local PowerShell or command-line instance to use Azure PowerShell or the Azure CLI. The Cloud Shell just provides convenience by already installing the tools and also authenticating to your Azure subscription.

Setting up the Cloud Shell for the first time

The first time you use Azure Cloud Shell, you will be prompted to set up a few dependent resources like a resource group, storage account, and an Azure Files share. Cloud Shell requires these resources to store the contents of your $HOME folder.

Note that when you set up Cloud Shell, it will create a storage account. That storage account will cost real money.

To begin, go to and authenticate your Azure subscription. Once you authenticate, you should be prompted to create a storage account as shown below. You could click on Create storage and have the service create everything for you.

Get hands-on with 1000+ tech skills courses.