We can install from Microsoft’s repo or install from PIP. However, when using system’s PIP, it would get:

/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.6) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "

The message is harmless, but annoying. I want to install it as my own user.

Install venv:

sudo apt -y install python3-venv

Create an environment for Azure CLI:

mkdir -p ~/.local/share/python3
python3 -m venv ~/.local/share/python3/env-az

Enable that:

source ~/.local/share/python3/env-az/bin/activate

Install Azure CLI:

pip install azure-cli


Everytime want to use the Azure CLI, just activate:

source ~/.local/share/python3/env-az/bin/activate

add to ~/.bashrc to have it permanent.

I’m using ~/.local/share path to have it FHS compliant.