In this article, I’ll walk you through everything you need to know about Azure Command-Line Interface ( Azure CLI), which provides you with a new way to interact with Azure resources.
What Is Azure CLI
The Azure Command-Line Interface (CLI) is a cross-platform command-line tool designed to create and manage Azure resources. Unlike the point-and-click nature of the Azure Portal, Azure CLI allows you to script and automate virtually any Azure operation through text-based commands.
Before diving into specific usage scenarios, let’s explore what makes Azure CLI such a powerful tool:
- Cross-platform compatibility: Works on Windows, macOS, and Linux
- Consistent command structure: Follows a predictable “az + resource + operation” pattern
- Output formatting options: Results can be formatted as JSON, table, or TSV
- Automation capabilities: Easily incorporated into scripts and CI/CD pipelines
- Query support: Filter and manipulate command outputs
- Multiple authentication methods: Support for service principals, managed identities, and interactive login
Installing Azure CLI
Getting started with Azure CLI is straightforward, regardless of your operating system. Here’s how you can typically set it up:
Windows Installation
# Using PowerShell (Run as Administrator)
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi
Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'Check out Install Azure CLI on Windows Without Admin Rights for more information.
macOS Installation
# Using brew
brew update && brew install azure-cliCheck out How to install Azure CLI on Mac for more information.
Linux Installation (Ubuntu/Debian)
# Add Microsoft signing key and repository
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
sudo apt-get update
sudo apt-get install azure-cliCheck out Install Azure CLI on Linux for more clarity.
After installation, I always verify the setup with:
az --versionThis displays the installed version and dependent libraries, confirming a successful installation.

Check out how to update Azure CLI
Getting Started with Azure CLI
Authentication Methods
Before you can use Azure CLI to manage resources, you need to authenticate. You can typically use one of these methods:
Interactive Login
For personal use or initial setup:
az loginThis opens a browser window where you can enter your Azure credentials.
Service Principal Authentication
For automated scripts and CI/CD pipelines:
az login --service-principal --username APP_ID --password PASSWORD --tenant TENANT_IDManaged Identity Authentication
When running from an Azure VM or service with a managed identity:
az login --identitySetting the Right Context
One practice I always emphasize to my teams is to verify your working context before executing commands:
# List subscriptions
az account list --output table
# Set the active subscription
az account set --subscription "My Subscription"Core Azure CLI Concepts
Understanding Azure CLI’s structure will help you become proficient quickly. All commands follow a consistent pattern:
az <resource-group> <resource-type> <command> [parameters]For example:
az vm create --resource-group MyResourceGroup --name MyVM --image UbuntuLTSCommand Groups and Subgroups
Azure CLI organizes commands into groups and subgroups representing Azure services and operations. Some common groups include:
az group– Resource group managementaz vm– Virtual machine operationsaz storage– Storage account managementaz network– Networking resourcesaz webapp– App Service applications
To explore available commands within a group, use:
az vm --help
Practical Azure CLI Examples
Let’s dive into some real-world examples I use regularly in my Azure projects:
Resource Group Management
# Create a new resource group
az group create --name MyProjectResources --location eastusAfter executing the above command, I got the expected output as shown in the screenshot below.

# List all resource groups
az group list --output tableAfter executing the above command, I got the expected output as shown in the screenshot below.

Working with Azure Storage
# Create a storage account
az storage account create --name azurelessonstrgeact --resource-group MyProjectResources --location eastus --sku Standard_LRSAfter executing the above command, I got the expected output as shown in the screenshot below.

# Create a blob container
az storage container create --name mycontainer --account-name azurelessonstrgeactAfter executing the above comman