Install the Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for managing Azure resources from your command line. Follow these instructions to install the Azure CLI on your operating system.

Prerequisites

Before you begin, ensure you have the following:

Installation Options

Windows

For Windows, you can use the MSI installer, Chocolatey, or Winget.

  • MSI Installer: Download the latest installer from the official download page.
  • Chocolatey: If you have Chocolatey installed, run:
    choco install azure-cli
  • Winget: If you have Winget installed, run:
    winget install Microsoft.AzureCLI

After installation, open a new command prompt or PowerShell window and run az --version to verify.

macOS

For macOS, you can use Homebrew or a script-based installer.

  • Homebrew: If you have Homebrew installed, run:
    brew update && brew install azure-cli
  • Script Installer: Run the following command to install via script:
    curl -sL https://aka.ms/InstallAzureCLI | bash

Verify the installation by running az --version in your terminal.

Linux

Supported distributions include Debian, Ubuntu, Fedora, CentOS, and RHEL. Installation methods vary by distribution.

Debian/Ubuntu

Use the package manager:

curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/$AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
sudo apt-get update
sudo apt-get install azure-cli

Fedora/CentOS/RHEL

Use the package manager:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo dnf install https://packages.microsoft.com/config/rhel/$(rpm -E %rhel)/azure-cli-rpms/azure-cli-2.xx.x-1.el$(rpm -E %rhel).noarch.rpm

Always check the official Linux installation guide for the most up-to-date commands and specific distribution instructions.

Cloud Shell

Azure Cloud Shell is an interactive, authenticated, browser-accessible shell for managing Azure resources. It includes the Azure CLI pre-installed.

  • Access Cloud Shell by clicking the >_ icon in the Azure portal's navigation bar.
  • Choose either Bash or PowerShell.
  • Cloud Shell is available on most modern web browsers.

This is the easiest way to get started without any local installation.

Verify Installation

Once installed, open a new terminal or command prompt window and run the following command to check the installed version:

az --version

You should see output similar to this:


Azure CLI 2.45.0

Core
    Extensions:
          account 2.2.16
          role 2.3.14

Python location '/usr/local/bin/python3'
Extensions directory '/Users/youruser/.azure/cliextensions'

Note: If you installed using a script or package manager, you might need to restart your terminal or log out and back in for the changes to take effect.

Tip: To keep your Azure CLI up-to-date, use the update commands specific to your installation method (e.g., az upgrade for some installations, or your system's package manager). You can also check for updates using az --version and comparing it with the latest release on GitHub.