Skip to content
Merged
Changes from 1 commit
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,53 +5,75 @@ ms.custom: devx-track-azurecli, linux-related-content

## Before you begin

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.
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.

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

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

Azure CLI has dropped support for Python 2.7 since version [2.1.0][02].

## Install or update Azure CLI

> [!IMPORTANT]
> 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.

Both installing and updating the Azure CLI requires rerunning the install script:
> 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.

```bash
curl -L https://aka.ms/InstallAzureCli | 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

# Refresh shell command cache (bash/zsh)
hash -r
```

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

## Uninstall Azure CLI
- To update later:

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

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).
## Uninstall Azure CLI

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

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

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

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

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

```bash
hash -r
Expand All @@ -66,48 +88,23 @@ installation. The default install location is the user's home directory ($HOME).
Here are some common problems seen during a manual installation. If you experience a problem not
covered here, [file an issue on GitHub][03].

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

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.
- Make sure `~/bin` is on your `PATH` (`echo $PATH`), the symlink exists (`ls -l ~/bin/az`), then
`hash -r` and reopen your shell.

### 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
```
- **SSL/crypto errors**

### Proxy blocks connection
- Ensure OpenSSL and libffi are installed for your distro and that your Python build links against
them.

[!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:
- Configure pip or environment variables (for example, `HTTPS_PROXY`) and allow access to:

- `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
- `https://pypi.org/`
- `https://files.pythonhosted.org/`
- Any endpoints used by your distro's package manager (for Python/venv prerequisites)

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

Expand Down