Install Azure CLI on macOS
The Azure Command-Line Interface (CLI) allows the execution of commands through a terminal using interactive command-line prompts or a script. You can install the Azure CLI locally on macOS computers. The Azure CLI on macOS allows the execution of various commands through a terminal using interactive command-line prompts or a script.
For the macOS platform, you can install the Azure CLI with homebrew package manager. Homebrew makes it easy to keep your installation of the CLI update to date. The CLI package has been tested on macOS versions 10.9 and later.
Install with Homebrew
Homebrew is the easiest way to manage your CLI install. It provides convenient ways to install, update, and uninstall. If you don't have homebrew available on your system, install homebrew before continuing.
You can install the Azure CLI on macOS by updating your brew repository information, and then running the
brew update && brew install azure-cli
The Azure CLI has a dependency on the Homebrew
python3 package, and will install it.
The Azure CLI is guaranteed to be compatible with the latest version of
published on Homebrew.
You can then run the Azure CLI with the
az command. To sign in, use az login command.
If the CLI can open your default browser, it will do so and load an Azure sign-in page.
Otherwise, open a browser page at https://aka.ms/devicelogin and enter the authorization code displayed in your terminal.
If no web browser is available or the web browser fails to open, use device code flow with az login --use-device-code.
Sign in with your account credentials in the browser.
To learn more about different authentication methods, see Sign in with Azure CLI.
If you encounter a problem when installing the CLI through Homebrew, here are some common errors. If you experience a problem not covered here, file an issue on github.
Completion is not working
The Homebrew formula of Azure CLI installs a completion file named
az in the Homebrew-managed completions directory (default location is
/usr/local/etc/bash_completion.d/). To enable completion, please follow Homebrew's instructions here.
Unable to find Python or installed packages
There may be a minor version mismatch or other issue during homebrew installation. The CLI doesn't use a Python virtual environment, so it relies on finding
the installed Python version. A possible fix is to install and relink the
python3 dependency from Homebrew.
brew update && brew install python3 && brew upgrade python3 brew link --overwrite python3
CLI version 1.x is installed
If an out-of-date version was installed, it could be because of a stale homebrew cache. Follow the update instructions.
Proxy blocks connection
You may be unable to get resources from Homebrew unless you have correctly configured it to use your proxy. Follow the Homebrew proxy configuration instructions.
If you are behind a proxy,
HTTPS_PROXY must be set to connect to Azure services with the CLI.
If you are not using basic auth, it's recommended to export these variables in your
Always follow your business' security policies and the requirements of your system administrator.
In order to get the bottle resources from Homebrew, your proxy needs to allow HTTPS connections to the following addresses:
The CLI is regularly updated with bug fixes, improvements, new features, and preview functionality. A new release is available roughly every three weeks.
The CLI provides an in-tool command to update to the latest version:
az upgrade command was added in version 2.11.0 and will not work with versions prior to 2.11.0. Older versions can be updated by reinstalling as described in Install the Azure CLI.
This command will also update all installed extensions by default. For more
az upgrade options, please refer to the command reference page.
You can also update your local Homebrew repository information and then upgrade the
brew update && brew upgrade azure-cli
If you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use the
az feedback command to let us know
what could be improved or fixed. Our goal is to make the Azure CLI bug-free and user-friendly. If you found a bug, we'd appreciate it if you file a GitHub issue.
Use homebrew to uninstall the
brew uninstall azure-cli
If you don't plan to reinstall Azure CLI, remove its data.
rm -rf ~/.azure
Other installation methods
If you can't use homebrew to install the Azure CLI in your environment, it's possible to use the manual instructions for Linux. Note that this process is not officially maintained to be compatible with macOS. Using a package manager such as Homebrew is always recommended. Only use the manual installation method if you have no other option available.
For the manual installation instructions, see Install Azure CLI on Linux manually.
Now that you've installed the Azure CLI on macOS, take a short tour of its features and common commands.