Skip to content

Commit 6fb80b5

Browse files
committed
Updated linux script install to use pip
1 parent 99c64ad commit 6fb80b5

File tree

1 file changed

+60
-67
lines changed

1 file changed

+60
-67
lines changed

docs-ref-conceptual/Latest-version/includes/cli-install-linux-script.md

Lines changed: 60 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,77 @@ ms.custom: devx-track-azurecli, linux-related-content
55

66
## Before you begin
77

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

12-
The install script for the Azure CLI requires the following software:
12+
> [!CAUTION]
13+
> This manual installation doesn't include a hash-based integrity check. When you run `pip install`,
14+
> the package is downloaded over HTTPS, but `pip` doesn't validate the file against a
15+
> Microsoft-provided hash. For stronger tamper protection, install Azure CLI through a package
16+
> manager that supports signature or hash verification.
1317
14-
- [Python 3.8.x, 3.9.x, 3.10.x][06] - For more information, see
15-
[Support lifecycle - Python dependency][01].
16-
- [libffi][04]
17-
- [OpenSSL 1.0.2][05]
18+
## Requirements
19+
20+
- [Python 3.10 or higher][04] - For more information, see
21+
[Support lifecycle - Python dependency][02].
22+
- `python3-venv` package for your distro
1823

1924
## Install or update Azure CLI
2025

2126
> [!IMPORTANT]
22-
> The install script only works on Python 3.8.x, 3.9.x, or 3.10.x. This install script does not work
23-
> on Python 3.11.x or later versions.
24-
25-
Both installing and updating the Azure CLI requires rerunning the install script:
27+
> These steps install Azure CLI into a **virtual environment** under your home directory and add a
28+
> symlink to `~/bin/az`. This keeps Azure CLI isolated from system Python and makes updates
29+
> straightforward.
2630
2731
```bash
28-
curl -L https://aka.ms/InstallAzureCli | bash
32+
# Create and activate a virtual environment
33+
python3 -m venv ~/lib/azure-cli
34+
source ~/lib/azure-cli/bin/activate
35+
36+
# Upgrade pip and install (or update) Azure CLI
37+
python -m pip install --upgrade pip
38+
pip install --upgrade azure-cli
39+
40+
# Expose 'az' on your PATH via a user bin folder
41+
mkdir -p ~/bin
42+
ln -sf ~/lib/azure-cli/bin/az ~/bin/az
43+
44+
# Ensure ~/bin is on PATH for future shells
45+
grep -q 'export PATH="$HOME/bin:$PATH"' ~/.bashrc || echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
46+
47+
# Refresh shell command cache (bash/zsh)
48+
hash -r
2949
```
3050

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

34-
## Uninstall Azure CLI
55+
- To update later:
3556

36-
[!INCLUDE [uninstall-boilerplate.md](uninstall-boilerplate.md)]
57+
```bash
58+
source ~/lib/azure-cli/bin/activate
59+
pip install --upgrade azure-cli
60+
hash -r
61+
```
3762

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

41-
1. Remove the installed CLI files.
65+
1. Remove the virtual environment and symlink.
4266

4367
```bash
44-
rm -r <install location>/lib/azure-cli
45-
rm <install location>/bin/az
68+
rm -rf ~/lib/azure-cli
69+
rm -f ~/bin/az
4670
```
4771

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

5074
```text
51-
<install location>/lib/azure-cli/az.completion
75+
export PATH="$HOME/bin:$PATH"
5276
```
5377

54-
1. If using `bash` or `zsh`, reload your shell's command cache.
78+
1. Refresh the shell command cache:
5579

5680
```bash
5781
hash -r
@@ -66,56 +90,25 @@ installation. The default install location is the user's home directory ($HOME).
6690
Here are some common problems seen during a manual installation. If you experience a problem not
6791
covered here, [file an issue on GitHub][03].
6892

69-
### Install without Python 3
70-
71-
The Azure CLI has dropped support for Python 2.7 since version [2.1.0][02]. On your system, there
72-
may be a Python version that predates the requirement of Python 3.6.x. Find a replacement `python3`
73-
package.
74-
75-
### curl "Object Moved" error
93+
- **`az: command not found`**
7694

77-
If you get an error from `curl` related to the `-L` parameter, or an error message including the
78-
text "Object Moved", try using the full URL instead of the `aka.ms` redirect:
79-
80-
```bash
81-
curl https://azurecliprod.blob.core.windows.net/install | bash
82-
```
95+
- Make sure `~/bin` is on your `PATH` (`echo $PATH`), the symlink exists (`ls -l ~/bin/az`), then
96+
`hash -r` and reopen your shell.
8397

84-
### `az` command not found
98+
- **Proxy issues**
8599

86-
If you can't run the command after installation using `bash` or `zsh`, try clearing your shell's
87-
command hash cache and check if the problem is resolved.
88-
89-
```bash
90-
hash -r
91-
```
92-
93-
The issue can also occur if you didn't restart your shell after installation. Make sure that the
94-
location of the `az` command is in your `$PATH`. The location of the `az` command is ...
95-
96-
```
97-
<install path>/bin
98-
```
99-
100-
### Proxy blocks connection
101-
102-
[!INCLUDE[configure-proxy](configure-proxy.md)]
103-
104-
In order to get the installation scripts, your proxy needs to allow HTTPS connections to the
105-
following addresses:
106-
107-
- `https://aka.ms/`
108-
- `https://azurecliprod.blob.core.windows.net/`
109-
- `https://pypi.python.org`
110-
- Endpoints used by your distribution's package manager (if any) for core packages
100+
- For proxy endpoint configuration, see [Azure CLI endpoints for proxy bypass][01].
111101

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

114104
<!-- link references -->
115105

116106
[01]: ../azure-cli-support-lifecycle.md#python-dependency
117-
[02]: /cli/azure/release-notes-azure-cli#february-18-2020
118107
[03]: https://github.com/Azure/azure-cli/issues
119-
[04]: https://sourceware.org/libffi/
120-
[05]: https://www.openssl.org/source/
121108
[06]: https://www.python.org/downloads/
109+
[07]: ../azure-cli-endpoints.md
110+
<!-- updated link references -->
111+
[01]: ../azure-cli-endpoints.md
112+
[02]: ../azure-cli-support-lifecycle.md#python-dependency
113+
[03]: https://github.com/Azure/azure-cli/issues
114+
[04]: https://www.python.org/downloads/

0 commit comments

Comments
 (0)