How to Install Azure CLI: Step-by-Step Guide
To install
Azure CLI, download and run the installer for your operating system from the official Microsoft site or use package managers like apt for Linux, brew for macOS, or msiexec for Windows. After installation, verify it by running az --version in your terminal or command prompt.Syntax
The basic command to check if Azure CLI is installed and to see its version is:
az --version: Shows the installed Azure CLI version and confirms installation.- Installation commands vary by operating system and package manager.
bash
az --version
Output
azure-cli 2.49.0
core 2.49.0
telemetry 1.0.8
Python location '/usr/local/azure-cli/bin/python3'
Extensions directory '/home/user/.azure/cliextensions'
Python (Linux) 3.10.6 (main, Apr 6 2023, 15:23:45) [GCC 11.3.0]
Legal docs and information: aka.ms/AzureCliLegal
Example
This example shows how to install Azure CLI on Ubuntu Linux using the official Microsoft package repository and then verify the installation.
bash
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az --versionOutput
Installing Azure CLI...
azure-cli 2.49.0
core 2.49.0
telemetry 1.0.8
Python location '/usr/local/azure-cli/bin/python3'
Extensions directory '/home/user/.azure/cliextensions'
Python (Linux) 3.10.6 (main, Apr 6 2023, 15:23:45) [GCC 11.3.0]
Legal docs and information: aka.ms/AzureCliLegal
Common Pitfalls
Common mistakes when installing Azure CLI include:
- Not running the installer with
sudoon Linux, causing permission errors. - Using outdated package sources that do not have the latest Azure CLI version.
- Not restarting the terminal after installation, so the
azcommand is not recognized. - Confusing Azure CLI with Azure PowerShell, which is a different tool.
bash
sudo apt-get update sudo apt-get install azure-cli # Wrong: missing sudo apt-get install azure-cli # Right: with sudo sudo apt-get install azure-cli
Quick Reference
Here is a quick summary of installation commands for different operating systems:
| Operating System | Installation Command |
|---|---|
| Windows | Download and run MSI installer from https://aka.ms/installazurecliwindows |
| macOS | brew update && brew install azure-cli |
| Ubuntu/Debian Linux | curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash |
| CentOS/RHEL Linux | sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo yum install azure-cli |
| Other Linux | Use package manager or install script from https://learn.microsoft.com/cli/azure/install-azure-cli |
Key Takeaways
Use the official Microsoft installer or package manager commands to install Azure CLI.
Always verify installation by running 'az --version' in your terminal.
Run installation commands with proper permissions, like using 'sudo' on Linux.
Restart your terminal after installation to ensure the 'az' command works.
Refer to the official Azure CLI documentation for the latest installation instructions.