Understanding Azure Cloud Shell, the Azure CLI and Azure PowerShell
This lesson explains Azure Cloud Shell, the Azure CLI and Azure PowerShell, how they relate to each other and how to choose between them.
Learning outcomes
After completing this lesson, you will be able to:
- Describe Azure Cloud Shell and its experiences.
- Distinguish the Azure CLI from Azure PowerShell.
- Identify the appropriate command-line tool for a scenario.
Azure Cloud Shell
Azure Cloud Shell is a browser-based shell tool for creating, configuring and managing Azure resources. It opens from the Azure portal toolbar or at shell.azure.com, and it is already authenticated with your Azure credentials, so there is nothing to install or sign in to. Cloud Shell offers two experiences: Bash and PowerShell, and both include the Azure CLI and Azure PowerShell, together with common tools such as Git, text editors, AzCopy, Terraform, kubectl and language runtimes.
Cloud Shell runs on a temporary host that Microsoft manages. You can mount an Azure file share to keep files in your home directory between sessions, or use an ephemeral session that needs no storage account, in which files are lost when the session ends. Cloud Shell is free; only the optional storage is billed.
Cloud Shell facts
Azure CLI and Azure PowerShell
The Azure CLI is a cross-platform command-line program that connects to Azure and runs administrative commands on Azure resources. Its commands start with az followed by a group and an action, and it is popular with people who use Bash. Azure PowerShell is a set of cmdlets, in the Az module, for managing Azure resources directly from PowerShell. Cmdlets use PowerShell's verb-noun naming, and it suits administrators who already script with PowerShell. The following commands create the same resource group with each tool.
# Azure CLI
az group create --name rg-demo --location westeurope
# Azure PowerShell
New-AzResourceGroup -Name rg-demo -Location westeuropeBoth tools can be installed on Windows, Linux and macOS and used locally or in Cloud Shell. Both can be used interactively, typing one command at a time, or in scripts that run many commands in sequence for automation. Functionally, they offer the same capabilities, and both send requests to Azure Resource Manager, so the choice is largely one of preference and existing skills.
CLI or PowerShell?
Comparing the tools
The following comparison summarizes the three tools.
az vm listGet-AzVMA locked-down workstation
An administrator needs to run several Azure CLI commands from a shared workstation on which they cannot install software. They also have a colleague who writes PowerShell scripts and wants to manage Azure with familiar cmdlets. What should each person use?
The administrator should use Azure Cloud Shell in the browser: it needs no installation, is already signed in and includes the Azure CLI. The colleague should use Azure PowerShell (the Az module), either installed locally or in the PowerShell experience of Cloud Shell. Both approaches manage the same resources through Azure Resource Manager.
Which two experiences does Azure Cloud Shell offer?
Show answer
Bash and PowerShell. Both include the Azure CLI and Azure PowerShell.
Exam Tips
Remember for the exam
- Cloud Shell is browser-based and pre-authenticated, with Bash and PowerShell experiences and tools preinstalled.
- Azure CLI commands start with az; Azure PowerShell uses verb-noun cmdlets such as New-AzResourceGroup.
- Both CLIs run on Windows, Linux and macOS, offer the same capabilities and support scripting.