|
| 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](install-azure-cli-macos.md). |
| 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 | +## Option 1 - Install 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](https://brew.sh/) 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 | +## Option 2 - Install 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 (M1, M2, M3, and newer) |
| 134 | +- `x86_64` - Intel-based Mac |
| 135 | + |
| 136 | +Selecting the correct architecture ensures compatibility and optimal performance. |
| 137 | + |
| 138 | +### Step 1: 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](https://github.com/Azure/azure-cli/releases) |
| 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 | +### Step 2: 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 | +### Step 3: 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 | +### Step 4: Verify installation |
| 184 | + |
| 185 | +```bash |
| 186 | +az --version |
| 187 | +``` |
| 188 | + |
| 189 | +### Upgrade (offline) |
| 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 (offline) |
| 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 | +## Migrate from Homebrew formula to cask |
| 211 | + |
| 212 | +If you previously installed Azure CLI using the Homebrew formula: |
| 213 | + |
| 214 | +```bash |
| 215 | +brew install azure-cli |
| 216 | +``` |
| 217 | + |
| 218 | +migrate to the cask installation: |
| 219 | + |
| 220 | +```bash |
| 221 | +brew uninstall azure-cli |
| 222 | +brew install --cask azure-cli |
| 223 | +``` |
| 224 | + |
| 225 | +Verify the installation: |
| 226 | + |
| 227 | +```bash |
| 228 | +az --version |
| 229 | +``` |
| 230 | + |
| 231 | +> [!IMPORTANT] |
| 232 | +> The Homebrew formula installation will be deprecated in a future release. |
| 233 | +
|
| 234 | +## Existing installations (Homebrew formula) |
| 235 | + |
| 236 | +Existing installations using the Homebrew formula will continue to work during the transition |
| 237 | +period. |
| 238 | + |
| 239 | +For current guidance, see [Install Azure CLI on macOS](install-azure-cli-macos.md). |
| 240 | + |
| 241 | +## Troubleshooting |
| 242 | + |
| 243 | +### Azure CLI not found |
| 244 | + |
| 245 | +Ensure your PATH includes the installation directory: |
| 246 | + |
| 247 | +```bash |
| 248 | +echo $PATH |
| 249 | +``` |
| 250 | + |
| 251 | +### Completion isn't working |
| 252 | + |
| 253 | +For Zsh, enable shell completion: |
| 254 | + |
| 255 | +```bash |
| 256 | +autoload bashcompinit && bashcompinit |
| 257 | +source $(brew --prefix)/etc/bash_completion.d/az |
| 258 | +``` |
| 259 | + |
| 260 | +### Proxy blocks connection |
| 261 | + |
| 262 | +If you're behind a proxy, configure your environment: |
| 263 | + |
| 264 | +- `HTTP_PROXY` |
| 265 | +- `HTTPS_PROXY` |
| 266 | + |
| 267 | +Ensure your proxy allows HTTPS access to: |
| 268 | + |
| 269 | +- [https://formulae.brew.sh](https://formulae.brew.sh) |
| 270 | +- [https://homebrew.bintray.com](https://homebrew.bintray.com) |
| 271 | + |
| 272 | +## Next steps |
| 273 | + |
| 274 | +After installation, sign in and begin using Azure CLI: |
| 275 | + |
| 276 | +```bash |
| 277 | +az login |
| 278 | +``` |
| 279 | + |
| 280 | +Explore available commands: |
| 281 | + |
| 282 | +```bash |
| 283 | +az find |
| 284 | +``` |
| 285 | + |
| 286 | +Learn more: |
| 287 | + |
| 288 | +[https://learn.microsoft.com/cli/azure/](https://learn.microsoft.com/cli/azure/) |
| 289 | + |
| 290 | +``` |
0 commit comments