# Azure CLI — Command Line Interface for Microsoft Azure > The Azure CLI provides cross-platform commands for creating and managing Azure resources, supporting scripted cloud operations and interactive exploration. ## Install Save in your project root: # Azure CLI — Command Line Interface for Microsoft Azure ## Quick Use ```bash # Install on Linux curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Login interactively az login # Create a resource group az group create --name myResourceGroup --location eastus # List VMs az vm list --output table ``` ## Introduction The Azure CLI (`az`) is Microsoft's official command-line tool for managing Azure cloud resources. Written in Python, it covers every Azure service through a consistent command structure and supports automation via scripts, CI/CD pipelines, and infrastructure-as-code workflows. ## What Azure CLI Does - Manages all Azure services through a hierarchical command structure (`az `) - Supports JSON, table, TSV, and YAML output formats for scripting and human consumption - Provides interactive mode with auto-completion and inline documentation - Handles authentication via browser login, service principals, managed identities, or device code flow - Includes `az bicep` commands for compiling and deploying Bicep infrastructure templates ## Architecture Overview The Azure CLI is a Python application built on the `knack` framework. It communicates with Azure Resource Manager (ARM) REST APIs, handling authentication tokens, API versioning, and request retries. Extensions add commands for services not yet in the core CLI. The tool stores session state and credentials in `~/.azure/` and supports multiple subscription contexts. ## Self-Hosting & Configuration - Install via `apt`, `yum`, `brew`, MSI installer, or the `mcr.microsoft.com/azure-cli` Docker image - Configure defaults with `az configure` for default output format, resource group, and location - Use service principals (`az ad sp create-for-rbac`) for non-interactive CI/CD authentication - Enable tab completion for bash, zsh, or PowerShell with `az completion` - Install extensions with `az extension add --name ` for preview or specialized services ## Key Features - Interactive mode (`az interactive`) with IntelliSense-style completion and scoping - JMESPath query support (`--query`) for filtering and transforming output - Bicep integration for deploying Azure infrastructure with a domain-specific language - What-if deployment previews show resource changes before applying ARM templates - Azure Cloud Shell provides a browser-based, pre-authenticated CLI environment ## Comparison with Similar Tools - **AWS CLI** — equivalent tool for Amazon Web Services - **gcloud CLI** — Google Cloud's command-line interface - **Azure PowerShell** — PowerShell module for Azure; more verbose but integrates with PowerShell scripting - **Terraform** — declarative IaC supporting Azure via the AzureRM provider - **Pulumi** — IaC in general-purpose languages with Azure support ## FAQ **Q: How do I switch between Azure subscriptions?** A: Use `az account set --subscription ` to change the active subscription context. **Q: Can I use the Azure CLI in CI/CD pipelines?** A: Yes. Authenticate with a service principal using `az login --service-principal` and environment variables for credentials. **Q: What is the difference between Azure CLI and Azure PowerShell?** A: Both manage Azure resources. Azure CLI uses a `az` command syntax designed for bash scripting. Azure PowerShell uses cmdlets following PowerShell conventions. **Q: Does the Azure CLI support all Azure services?** A: Core services are built in. Newer or preview services may require installing CLI extensions via `az extension add`. ## Sources - https://github.com/Azure/azure-cli - https://learn.microsoft.com/en-us/cli/azure/ --- Source: https://tokrepo.com/en/workflows/asset-8e62295d Author: AI Open Source