Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,53 @@ ms.custom: devx-track-azurecli, linux-related-content

## Before you begin

It's strongly recommended to install the Azure CLI with a package manager. A package manager makes
sure you always get the latest updates, and guarantees the stability of Azure CLI components. Check
and see if there's a package for your distribution before installing manually.
It's strongly recommend to install the CLI with a package manager. A package manager makes sure you
always get the latest updates, and guarantees the stability of CLI components. Check and see if
there's a package for your distribution before installing manually.

## Requirements
The install script for the Azure CLI requires the following software:

- [Python 3.10 or higher][06] - For more information, see
- [Python 3.8.x, 3.9.x, 3.10.x][06] - For more information, see
[Support lifecycle - Python dependency][01].
- `python3-venv` package for your distro
- [libffi][04]
- [OpenSSL 1.0.2][05]

## Install or update Azure CLI

> [!IMPORTANT]
> These steps install Azure CLI into a **virtual environment** under your home directory and add a
> symlink to `~/bin/az`. This keeps Azure CLI isolated from system Python and makes updates
> straightforward.
> The install script only works on Python 3.8.x, 3.9.x, or 3.10.x. This install script does not work
> on Python 3.11.x or later versions.

```bash
# Create and activate a virtual environment
python3 -m venv ~/lib/azure-cli
source ~/lib/azure-cli/bin/activate

# Upgrade pip and install (or update) Azure CLI
python -m pip install --upgrade pip
pip install --upgrade azure-cli

# Expose 'az' on your PATH via a user bin folder
mkdir -p ~/bin
ln -sf ~/lib/azure-cli/bin/az ~/bin/az

# Ensure ~/bin is on PATH for future shells
grep -q 'export PATH="$HOME/bin:$PATH"' ~/.bashrc || echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
Both installing and updating the Azure CLI requires rerunning the install script:

# Refresh shell command cache (bash/zsh)
hash -r
```bash
curl -L https://aka.ms/InstallAzureCli | bash
```

> [!NOTE]
> If you're using zsh, replace `.bashrc` with `.zshrc` in the PATH update command so the change
applies to future zsh sessions.
The script can also be downloaded and run locally. You may have to restart your shell for the
changes to take effect.

- To update later:
## Uninstall Azure CLI

```bash
source ~/lib/azure-cli/bin/activate
pip install --upgrade azure-cli
hash -r
```
[!INCLUDE [uninstall-boilerplate.md](uninstall-boilerplate.md)]

## Uninstall Azure CLI
Uninstall the CLI by directly deleting the files from the location chosen at the time of
installation. The default install location is the user's home directory ($HOME).

1. Remove the virtual environment and symlink.
1. Remove the installed CLI files.

```bash
rm -rf ~/lib/azure-cli
rm -f ~/bin/az
rm -r <install location>/lib/azure-cli
rm <install location>/bin/az
```

1. (Optional) Remove the PATH line from your shell profile if you added it:
1. Modify your `$HOME/.bash_profile` file to remove the following line:

```text
export PATH="$HOME/bin:$PATH"
<install location>/lib/azure-cli/az.completion
```

1. Refresh the shell command cache:
1. If using `bash` or `zsh`, reload your shell's command cache.

```bash
hash -r
Expand All @@ -84,20 +66,56 @@ applies to future zsh sessions.
Here are some common problems seen during a manual installation. If you experience a problem not
covered here, [file an issue on GitHub][03].

- **`az: command not found`**
### Install without Python 3

The Azure CLI has dropped support for Python 2.7 since version [2.1.0][02]. On your system, there
may be a Python version that predates the requirement of Python 3.6.x. Find a replacement `python3`
package.

### curl "Object Moved" error

If you get an error from `curl` related to the `-L` parameter, or an error message including the
text "Object Moved", try using the full URL instead of the `aka.ms` redirect:

```bash
curl https://azurecliprod.blob.core.windows.net/install | bash
```

### `az` command not found

If you can't run the command after installation using `bash` or `zsh`, try clearing your shell's
command hash cache and check if the problem is resolved.

```bash
hash -r
```

The issue can also occur if you didn't restart your shell after installation. Make sure that the
location of the `az` command is in your `$PATH`. The location of the `az` command is ...

```
<install path>/bin
```

### Proxy blocks connection

- Make sure `~/bin` is on your `PATH` (`echo $PATH`), the symlink exists (`ls -l ~/bin/az`), then
`hash -r` and reopen your shell.
[!INCLUDE[configure-proxy](configure-proxy.md)]

- **Proxy issues**
In order to get the installation scripts, your proxy needs to allow HTTPS connections to the
following addresses:

- For proxy endpoint configuration, see [Azure CLI endpoints for proxy bypass][07].
- `https://aka.ms/`
- `https://azurecliprod.blob.core.windows.net/`
- `https://pypi.python.org`
- Endpoints used by your distribution's package manager (if any) for core packages

[!INCLUDE[troubleshoot-wsl.md](troubleshoot-wsl.md)]

<!-- link references -->

[01]: ../azure-cli-support-lifecycle.md#python-dependency
[02]: /cli/azure/release-notes-azure-cli#february-18-2020
[03]: https://github.com/Azure/azure-cli/issues
[04]: https://sourceware.org/libffi/
[05]: https://www.openssl.org/source/
[06]: https://www.python.org/downloads/
[07]: ../azure-cli-endpoints.md