|
| 1 | +--- |
| 2 | +title: Install Azure CLI on macOS using Homebrew Cask or Tarball preview |
| 3 | +description: Install Azure CLI on macOS using Homebrew Cask or Tarball. Includes offline setup, upgrade, uninstall, and migration guidance. |
| 4 | +ms.service: azure-cli |
| 5 | +ms.custom: devx-track-azurecli |
| 6 | +zone_pivot_group_filename: azure/zone-pivot-groups.json |
| 7 | +zone_pivot_groups: cli-macos-installation-method |
| 8 | +keywords: Install azure cli, azure cli macos, macos cli, install azure cli macos |
| 9 | +--- |
| 10 | + |
| 11 | +# Install Azure CLI on macOS using Homebrew Cask or Tarball preview |
| 12 | + |
| 13 | +Azure CLI is a cross-platform command-line tool used to manage Azure resources from the command line |
| 14 | +or through scripts. |
| 15 | + |
| 16 | +On macOS, Azure CLI is transitioning to a new installation model that provides greater flexibility |
| 17 | +across environments. This model includes: |
| 18 | + |
| 19 | +- Homebrew Cask (recommended for most users) |
| 20 | +- Tarball (recommended for offline, restricted, or custom environments) |
| 21 | + |
| 22 | +This experience is currently in preview and will become the standard installation approach in a |
| 23 | +future release. |
| 24 | + |
| 25 | +> [!NOTE] |
| 26 | +> For the current stable installation guidance, see [Install Azure CLI on macOS][01]. |
| 27 | +
|
| 28 | +## What is changing |
| 29 | + |
| 30 | +Azure CLI installation on macOS is moving away from the Homebrew formula to a more maintainable and |
| 31 | +flexible model. |
| 32 | + |
| 33 | +- Current method: `brew install azure-cli` |
| 34 | +- New methods: |
| 35 | + - `brew install --cask azure-cli` |
| 36 | + - Tarball-based installation |
| 37 | + |
| 38 | +During the transition period, both installation methods are supported. The Homebrew formula will be |
| 39 | +deprecated in a future release. |
| 40 | + |
| 41 | +This change improves consistency across environments and provides better support for scenarios such |
| 42 | +as offline installation and controlled deployment environments. |
| 43 | + |
| 44 | +## Choose an installation method |
| 45 | + |
| 46 | +Use the following guidance to select the installation method that best fits your scenario: |
| 47 | + |
| 48 | +| Scenario | Recommended method | |
| 49 | +| -------------------------------- | ------------------ | |
| 50 | +| Most users | Homebrew Cask | |
| 51 | +| Offline or air-gapped systems | Tarball | |
| 52 | +| Custom install location required | Tarball | |
| 53 | + |
| 54 | +::: zone pivot="cask" |
| 55 | + |
| 56 | +## Install Azure CLI using Homebrew Cask |
| 57 | + |
| 58 | +Homebrew provides the simplest and most maintainable installation experience for Azure CLI on macOS. |
| 59 | +It handles installation, upgrades, and removal using standard package management workflows. |
| 60 | + |
| 61 | +### Prerequisites |
| 62 | + |
| 63 | +- macOS (Apple Silicon or Intel) |
| 64 | +- [Homebrew][02] installed |
| 65 | + |
| 66 | +If Azure CLI is already installed using the Homebrew formula, uninstall it before proceeding to |
| 67 | +avoid conflicts: |
| 68 | + |
| 69 | +```bash |
| 70 | +brew uninstall azure-cli |
| 71 | +``` |
| 72 | + |
| 73 | +### Install Azure CLI |
| 74 | + |
| 75 | +```bash |
| 76 | +brew update && brew install --cask azure-cli |
| 77 | +``` |
| 78 | + |
| 79 | +This installs Azure CLI using the Homebrew Cask, which is the preferred installation method going |
| 80 | +forward. |
| 81 | + |
| 82 | +### Verify installation |
| 83 | + |
| 84 | +After installation, confirm Azure CLI is available: |
| 85 | + |
| 86 | +```bash |
| 87 | +az --version |
| 88 | +``` |
| 89 | + |
| 90 | +## Upgrade Azure CLI |
| 91 | + |
| 92 | +To upgrade to the latest version: |
| 93 | + |
| 94 | +```bash |
| 95 | +brew upgrade --cask azure-cli |
| 96 | +``` |
| 97 | + |
| 98 | +## Uninstall Azure CLI |
| 99 | + |
| 100 | +To remove Azure CLI: |
| 101 | + |
| 102 | +```bash |
| 103 | +brew uninstall --cask azure-cli |
| 104 | +``` |
| 105 | + |
| 106 | +::: zone-end |
| 107 | + |
| 108 | +::: zone pivot="tarball" |
| 109 | + |
| 110 | +## Install Azure CLI using a Tarball |
| 111 | + |
| 112 | +Use this method if: |
| 113 | + |
| 114 | +- Homebrew isn't available |
| 115 | +- Internet access is restricted |
| 116 | +- You need full control over the installation location |
| 117 | + |
| 118 | +This method is commonly used in enterprise, regulated, or air-gapped environments. |
| 119 | + |
| 120 | +### Prerequisites |
| 121 | + |
| 122 | +- macOS (Apple Silicon or Intel) |
| 123 | +- Python 3.13 installed using your preferred method (for example, `python.org` or `pyenv`) |
| 124 | + |
| 125 | +## Determine your architecture |
| 126 | + |
| 127 | +Before downloading the Tarball, determine your system architecture: |
| 128 | + |
| 129 | +```bash |
| 130 | +uname -m |
| 131 | +``` |
| 132 | + |
| 133 | +- `arm64` - Apple Silicon |
| 134 | +- `x86_64` - Intel |
| 135 | + |
| 136 | +Selecting the correct architecture ensures compatibility and optimal performance. |
| 137 | + |
| 138 | +### Download the Tarball |
| 139 | + |
| 140 | +On a machine with internet access, download the desired Azure CLI release from: |
| 141 | + |
| 142 | +[https://github.com/Azure/azure-cli/releases][03] |
| 143 | + |
| 144 | +Example: |
| 145 | + |
| 146 | +```bash |
| 147 | +# Replace <version> and <arch> |
| 148 | +curl -L -o azure-cli-<version>-macos-<arch>.tar.gz \ |
| 149 | + https://github.com/Azure/azure-cli/releases/download/azure-cli-<version>/azure-cli-<version>-macos-<arch>.tar.gz |
| 150 | +``` |
| 151 | + |
| 152 | +> [!TIP] |
| 153 | +> For offline environments, transfer the Tarball to the target system using a secure method such as |
| 154 | +> removable media or secure file transfer. |
| 155 | +
|
| 156 | +### Extract to installation directory |
| 157 | + |
| 158 | +Choose a directory where Azure CLI should be installed: |
| 159 | + |
| 160 | +```bash |
| 161 | +sudo mkdir -p /target_directory_path |
| 162 | +sudo tar -xzf azure-cli-<version>-macos-<arch>.tar.gz -C /target_directory_path |
| 163 | +``` |
| 164 | + |
| 165 | +### Configure environment variables |
| 166 | + |
| 167 | +Azure CLI requires access to a Python runtime. Configure your environment to point to Python and the |
| 168 | +Azure CLI binaries. |
| 169 | + |
| 170 | +Add the following to your shell profile (`~/.zshrc` or `~/.bashrc`): |
| 171 | + |
| 172 | +```bash |
| 173 | +export AZ_PYTHON="/path_to_python" |
| 174 | +export PATH="/target_directory_path/bin:$PATH" |
| 175 | +``` |
| 176 | + |
| 177 | +Reload your shell configuration: |
| 178 | + |
| 179 | +```bash |
| 180 | +source ~/.zshrc |
| 181 | +``` |
| 182 | + |
| 183 | +### Verify installation |
| 184 | + |
| 185 | +```bash |
| 186 | +az --version |
| 187 | +``` |
| 188 | + |
| 189 | +## Upgrade Azure CLI |
| 190 | + |
| 191 | +To upgrade Azure CLI in an offline environment, download a newer Tarball and extract it over the |
| 192 | +existing installation: |
| 193 | + |
| 194 | +```bash |
| 195 | +sudo tar -xzf azure-cli-<version>-macos-<arch>.tar.gz -C /target_directory_path |
| 196 | +``` |
| 197 | + |
| 198 | +### Uninstall Azure CLI |
| 199 | + |
| 200 | +Remove the installation directory: |
| 201 | + |
| 202 | +```bash |
| 203 | +sudo rm -rf /target_directory_path |
| 204 | +``` |
| 205 | + |
| 206 | +Then remove the `AZ_PYTHON` and `PATH` entries from your shell profile. |
| 207 | + |
| 208 | +::: zone-end |
| 209 | + |
| 210 | +## Troubleshooting |
| 211 | + |
| 212 | +If you encounter a problem when installing the Azure CLI through Homebrew, here are some common |
| 213 | +errors. If you experience a problem not covered here, [file an issue on GitHub][04]. |
| 214 | + |
| 215 | +### Azure CLI not found |
| 216 | + |
| 217 | +Ensure your PATH includes the installation directory: |
| 218 | + |
| 219 | +```bash |
| 220 | +echo $PATH |
| 221 | +``` |
| 222 | + |
| 223 | +### Completion isn't working |
| 224 | + |
| 225 | +The Homebrew formula of Azure CLI installs a completion file named `az` in the Homebrew-managed |
| 226 | +completions directory (default location is `/usr/local/etc/bash_completion.d/`). To enable |
| 227 | +completion, follow [Homebrew's instructions][05]. |
| 228 | + |
| 229 | +For Zsh, add the following two lines to the bottom of your `.zshrc` file, then save and reload your |
| 230 | +Zsh profile. |
| 231 | + |
| 232 | +```bash |
| 233 | +autoload bashcompinit && bashcompinit |
| 234 | +source $(brew --prefix)/etc/bash_completion.d/az |
| 235 | +``` |
| 236 | + |
| 237 | +### Unable to find Python or installed packages |
| 238 | + |
| 239 | +There might be a minor version mismatch or other issue during homebrew installation. Azure CLI |
| 240 | +doesn't use a Python virtual environment, so it relies on finding the installed Python version. A |
| 241 | +possible fix is to install and relink the `python@3.13` dependency from Homebrew. |
| 242 | + |
| 243 | +```bash |
| 244 | +brew update && brew install python@3.13 && brew upgrade python@3.13 |
| 245 | +brew link --overwrite python@3.13 |
| 246 | +``` |
| 247 | + |
| 248 | +### Proxy blocks connection |
| 249 | + |
| 250 | +You might be unable to get resources from Homebrew unless you configure it to use your proxy. Follow |
| 251 | +the [Homebrew proxy configuration instructions][06]. |
| 252 | + |
| 253 | +> [!IMPORTANT] |
| 254 | +> If you are behind a proxy, `HTTP_PROXY` and `HTTPS_PROXY` must be set to connect to Azure services |
| 255 | +> with the Azure CLI. If you don't use basic auth, you should export these variables in your |
| 256 | +> `.bashrc` file. Always follow your business' security policies and the requirements of your system |
| 257 | +> administrator. |
| 258 | +
|
| 259 | +To get the bottle resources from Homebrew, your proxy needs to allow HTTPS connections to the |
| 260 | +following addresses: |
| 261 | + |
| 262 | +- `https://formulae.brew.sh` |
| 263 | +- `https://homebrew.bintray.com` |
| 264 | + |
| 265 | +## Next Steps |
| 266 | + |
| 267 | +Now that you installed the Azure CLI on macOS, take a short tour of its features and common |
| 268 | +commands. |
| 269 | + |
| 270 | +> [!div class="nextstepaction"] |
| 271 | +> [Get started with the Azure CLI][07] |
| 272 | +
|
| 273 | +<!-- link references --> |
| 274 | + |
| 275 | +[01]: install-azure-cli-macos.md |
| 276 | +[02]: https://brew.sh/ |
| 277 | +[03]: https://github.com/Azure/azure-cli/releases |
| 278 | +[04]: https://github.com/Azure/azure-cli/issues |
| 279 | +[05]: https://docs.brew.sh/Shell-Completion |
| 280 | +[06]: https://docs.brew.sh/Manpage#using-homebrew-behind-a-proxy |
| 281 | +[07]: get-started-with-azure-cli.md |
0 commit comments