When it comes to managing Azure, you have many options. This article compares the Azure CLI and Azure PowerShell language and gives a comparison of the shell environments on which they run.
Azure CLI, Azure PowerShell, and Azure Cloud Shell have overlapping functionality. Each operates differently, and the language is sometimes confused with the environment. Use this guide to determine which is the right tool for you.
What's the advantage of using an Azure command-line tool?
Azure runs on automation. Every action you take inside the portal translates somewhere to code being executed to read, create, modify, or delete resources.
Moving your workload to Azure lifts some of the administrative burden but not all. As your rate of adoption with Azure increases so will the overhead. Even though you don't have to worry about the data center, you still have to patch and troubleshoot Azure VMs, failover databases, and configure virtual networks.
By using the existing automation that runs Azure, command-line tools reduce that overhead.
What are Azure command-line tools?
Azure command-line tools automate routine operations, standardize database failovers, and pull data that provide powerful insight. Command-line tools not only give you the ability to scale your tasks in Azure, but they also make much easier to share. Sharing a script is much easier than a lengthy wiki page with time consuming screenshots.
Using an Azure command-line tool isn't always necessary, but it's a useful skill to have.
Azure CLI vs Azure PowerShell
Azure CLI and Azure PowerShell are command-line tools that enable you to create and manage Azure resources. Both are cross-platform, installable
on Windows, macOS, and Linux.
Azure CLI
Cross-platform command-line interface, installable on Windows, macOS, Linux
Runs in Windows PowerShell, Cmd, or Bash and other Unix shells.
Azure PowerShell
Cross-platform PowerShell module, runs on Windows, macOS, Linux
Requires Windows PowerShell or PowerShell
Different shell environments
Shell Environment
Azure CLI
Azure PowerShell
Cmd
Yes
Bash
Yes
Windows PowerShell
Yes
Yes
PowerShell
Yes
Yes
Windows PowerShell, PowerShell, Cmd, and Bash are shell environments. Your shell environment not only determines which tools you can use but also changes your command-line experience.
For example, for the line continuation character, Bash uses the backslash \ while Windows PowerShell uses the backtick `. The differences in the shell environment doesn't change how Azure CLI and Azure PowerShell operate. However, they do change your command-line experience.
Azure CLI has an installer that makes its commands executable in all four shell environments.
Azure PowerShell is set of cmdlets packaged as a PowerShell module named Az; not an executable. Windows PowerShell or PowerShell must be used to install the Az module.
Windows PowerShell is the standard scripting shell that comes preinstalled with most Windows operating systems. PowerShell is a stand-alone installation that uses .NET Core as it's run time, allowing it to be installed on macOS, Linux, and Windows.
Key points:
AzureRM is a PowerShell module that is still referenced for Azure administration with PowerShell. However, it has been replaced by Azure PowerShell and has an official retirement date of February 29 2024.
Azure Cloud Shell is a hosted shell environment that runs on an Ubuntu container.
Cloud Shell provides two shell environments: Bash (with Azure CLI preinstalled) and PowerShell (with Azure PowerShell preinstalled). A dropdown list at the top of the Cloud Shell window allows you to easily switch between the two environments.
Azure Cloud Shell may not always immediately reflect the most recent Azure PowerShell and Azure CLI releases as the publishing schedule for all three tools is different. However, Azure Cloud Shell is generally thought to always contain the most recent versions of both tools.
Which Azure command-line tool is right for you?
When picking the right tool, consider your past experience and current work environment.
Azure CLI syntax is similar to that of Bash scripting. If you work primarily with Linux systems, Azure CLI feels more natural.
Azure PowerShell is a PowerShell module. If you work primarily with Windows systems, Azure PowerShell is a natural fit. Commands follow a verb-noun naming scheme and
data is returned as objects.
Choose the tool that uses your experience and shortens your learning curve. Take advantage of Microsoft learning to become proficient at managing Azure at the command line.
With that said, being open-minded will only improve your abilities. Use a different tool when it makes sense.
Key points:
Feature parity for Azure services doesn't always exist between Azure CLI and Azure PowerShell.
Azure CLI vs Azure PowerShell: Side-by-side Command Comparison
Sign in, Subscription, and Location Commands:
Command
Azure CLI
Azure PowerShell
Sign in with Web Browser
az login
Connect-AzAccount
Get available subscriptions
az account list
Get-AzSubscription
Set Subscription
az account set –-subscription <SubscriptionId>
Set-AzContext -Subscription <SubscriptionID>
List Azure Locations
az account list-locations
Get-AzLocation
Find Versions, Get Help, and View Command Help:
Command
Azure CLI
Azure PowerShell
Find Version
az --version
Get-InstalledModule -Name Az
Get Help
az --help
Get-Help
View Command Help
az vm --help
Get-Help -Name New-AzVM
Create a Resource Group, VM, and Storage Account:
Command
Azure CLI
Azure PowerShell
Create Resource Group
az group create --name <ResourceGroupName> --location eastus
Šio turinio šaltinį galima rasti „GitHub“, kur taip pat galite kurti ir peržiūrėti problemas bei teikti užklausas. Daugiau informacijos žr. mūsų bendraautorių vadove.
Azure CLI atsiliepimas
Azure CLI yra atvirojo kodo projektas. Pasirinkite saitą, kad pateiktumėte atsiliepimą:
Conozca los conceptos básicos de infraestructura como código, explore las diferencias clave entre la CLI de Azure, Azure PowerShell, Bicep y Terraform, y decida qué herramientas de línea de comandos satisfacen mejor las necesidades de la organización.
Aprendizaje de Bash mediante la CLI de Azure Obtenga información sobre cómo realizar consultas y filtrados, formatear la salida y usar variables, así como construcciones Bash con bucles, if/exists/then e instrucciones case.
Obtenga información sobre las diferencias entre comillas, la continuación de línea y la depuración en bash, PowerShell y lenguajes de scripting de Windows Cmd.
Obtenga información sobre los entornos que puede usar para ejecutar comandos de la CLI de Azure, términos de la CLI de Azure, cómo se compara la CLI de Azure con Azure PowerShell.
Aprenda a crear varios recursos de Azure a partir de un script y registrar el progreso en un archivo. El script de la CLI de Azure se proporciona tanto para Bash como para PowerShell.