When your shell prints az: command not found, it searched every directory in your PATH and found no executable named az. There are only two possible causes: the Azure CLI is not installed, or it is installed somewhere your PATH does not cover.
$ az login
bash: az: command not found
$ az --version
zsh: command not found: az
One command tells you which one you have:
command -v az
If it prints a path, the CLI is installed and you have a PATH problem. If it prints nothing, you have an installation problem. Do not skip this step — the two have completely different fixes, and guessing wastes the most time.
Fix 1: Restart Your Terminal First (Windows Especially)
Before reinstalling anything, close the terminal and open a new one.
A running shell keeps the environment it started with, so an installer that adds a directory to PATH has no effect on windows that were already open. Microsoft states this directly in the Windows install guide: after installation you must close and reopen any active terminal window to use the Azure CLI, and lists "PATH variable not set" as most commonly caused by exactly this.
This applies to VS Code's integrated terminal too — reload the window, or the terminal keeps the environment VS Code inherited at launch.
Fix 2: Install the Azure CLI
Ubuntu, Debian, and WSL
The maintained one-line script runs every documented step:
curl -fsSL 'https://azurecliprod.blob.core.windows.net/$root/deb_install.sh' | sudo bash
If you would rather inspect each step — reasonable for a script running as root — do it manually:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -sLS https://packages.microsoft.com/keys/microsoft.asc |
gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/microsoft.gpg
AZ_DIST=$(lsb_release -cs)
echo "Types: deb
URIs: https://packages.microsoft.com/repos/azure-cli/
Suites: ${AZ_DIST}
Components: main
Architectures: $(dpkg --print-architecture)
Signed-by: /etc/apt/keyrings/microsoft.gpg" | sudo tee /etc/apt/sources.list.d/azure-cli.sources
sudo apt-get update
sudo apt-get install azure-cli
If apt replies Unable to locate package azure-cli, the repository step did not take effect — azure-cli is not in the stock Ubuntu or Debian archives. Re-run the repository and key steps, then apt-get update again.
On Linux Mint and other derivatives, lsb_release -cs may return a name Microsoft does not publish packages for. Set the Suites: value manually to the upstream code name your distribution is based on, such as jammy for Ubuntu or bookworm for Debian.
RHEL, CentOS Stream, and Fedora
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo dnf install -y https://packages.microsoft.com/config/rhel/9.0/packages-microsoft-prod.rpm
sudo dnf install azure-cli
macOS
brew update && brew install azure-cli
Windows
winget install --exact --id Microsoft.AzureCLI
The MSI installer is the alternative, and it overwrites any existing installation, so you do not need to uninstall first. Either way — close and reopen your terminal afterwards.
Fix 3: Repair a Broken PATH
If command -v az printed a path but a new shell still cannot find it, the directory is missing from your shell profile. Find the binary, then add its directory:
ls -l /usr/bin/az /usr/local/bin/az /opt/homebrew/bin/az 2>/dev/null
echo "$PATH" | tr ':' '\n'
Add the directory to the profile your shell actually reads — ~/.zshrc for zsh (the macOS default), ~/.bashrc or ~/.bash_profile for bash:
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
On Apple Silicon Macs, Homebrew installs to /opt/homebrew; on Intel Macs it is /usr/local. Following an Intel-era guide on an Apple Silicon machine is a routine cause of this error.
Two more environment-specific cases:
sudo az ...fails whileaz ...works.sudoresetsPATHfor security. You almost never needsudoforaz— it operates on cloud resources, not local system files.- cron and CI runners start with a minimal
PATH. Use the absolute path to the binary, or setPATHexplicitly at the top of the job.
Verify the Fix
az version
command -v az
Then confirm the CLI can actually reach Azure:
az login
az account show
az account show returning your subscription confirms installation, PATH, and authentication are all working. From there you can move on to real work, such as creating a storage account or assigning roles.
Prevent It From Recurring
- Install through a package manager — apt, dnf, Homebrew, or WinGet — so upgrades and
PATHare handled for you. Avoidsudo pip install, which creates root-owned files that break later upgrades. - Keep PATH edits in one place. Duplicated exports scattered across
.bashrc,.zshrc, and.profileare how these errors reappear months later. - Open a new terminal after any install rather than debugging a stale environment.
- Pin the CLI version in CI and install it as an explicit build step, so a runner image change cannot silently remove it.
- Update in place with
az upgradeinstead of layering a second installation on top of the first.