Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure CLI preview ships shell completion scripts for bash, zsh, and PowerShell. Once enabled, pressing <Tab> completes command groups, subcommands, and parameters for the az command. Completions are resolved by calling az at tab-time, so they always match the installed CLI.
Where the scripts live
The completion scripts are included in the CLI archive under completions/. After a default install they are at:
| Platform | Default location |
|---|---|
| Linux / macOS | ~/.local/share/azcli/completions/ |
| Windows | %LOCALAPPDATA%\Programs\azcli\completions\ |
Files: az.completions.bash, az.completions.zsh, az.completions.ps1. If you installed azcli to a custom location, use <install-root>/completions/ instead.
Enable it
bash
# Try it in the current shell
source ~/.local/share/azcli/completions/az.completions.bash
# Make it permanent (and load it now)
echo 'source ~/.local/share/azcli/completions/az.completions.bash' >> ~/.bashrc
source ~/.bashrc
zsh
# Ensure the completion system is initialised
autoload -U compinit && compinit
# Try it in the current shell
source ~/.local/share/azcli/completions/az.completions.zsh
# Make it permanent (and load it now)
echo 'autoload -U compinit && compinit' >> ~/.zshrc
echo 'source ~/.local/share/azcli/completions/az.completions.zsh' >> ~/.zshrc
source ~/.zshrc
PowerShell
# Try it in the current session
. "$env:LOCALAPPDATA\Programs\azcli\completions\az.completions.ps1"
# Make it permanent (adds to your PowerShell profile)
if (-not (Test-Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
Add-Content -LiteralPath $PROFILE '. "$env:LOCALAPPDATA\Programs\azcli\completions\az.completions.ps1"'
. $PROFILE
Try it
az <Tab> # top-level groups
az vm <Tab> # subcommands
az vm create --<Tab> # parameters
Turn completion on or off
Completion is enabled by default. You can toggle it through config without un-sourcing the script — the CLI is the source of truth, so a disabled setting makes every shell stop offering suggestions:
az config set --key completion.enabled --value false # disable
az config set --key completion.enabled --value true # enable
Remove tab completion from your shell
To stop loading the completion script, remove the line that you added to your shell profile, and then open a new shell. To only stop suggestions without editing your profile, set completion.enabled to false instead, as described in the previous section.
bash
Delete the source line from ~/.bashrc:
sed -i.bak '\|azcli/completions/az.completions.bash|d' ~/.bashrc
The command saves a backup of the original file as ~/.bashrc.bak.
zsh
Delete the source line from ~/.zshrc:
sed -i.bak '\|azcli/completions/az.completions.zsh|d' ~/.zshrc
Keep the autoload -U compinit && compinit line if other tools rely on zsh completion. Otherwise, you can remove it too.
PowerShell
Remove the line that dot-sources the script from your PowerShell profile:
$lines = Get-Content -LiteralPath $PROFILE | Where-Object { $_ -notmatch 'azcli\\completions\\az\.completions\.ps1' }
Set-Content -LiteralPath $PROFILE -Value $lines
You can also open the profile in an editor with code $PROFILE or notepad $PROFILE and delete the line manually.
Refresh and troubleshoot
| Symptom | Fix |
|---|---|
| No suggestions appear | Confirm az resolves to azcli (which az / Get-Command az) and that you sourced the script for your shell. |
| Stale suggestions after updating azcli | Refresh the session cache: _az_clear_cache (bash/zsh) or _azClearCache (PowerShell). |
zsh: compdef: command not found |
Add autoload -U compinit && compinit before sourcing the script. |
| Want to see what's happening (zsh) | export AZ_COMPLETION_DEBUG=1 (log written to /tmp/az_completion_debug.log). |