@@ -5,53 +5,75 @@ 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+ ## Requirements
1313
14- - [ Python 3.8.x, 3.9.x, 3.10.x ] [ 06 ] - For more information, see
14+ - [ Python 3.8 or higher ] [ 06 ] - For more information, see
1515 [ Support lifecycle - Python dependency] [ 01 ] .
1616- [ libffi] [ 04 ]
1717- [ OpenSSL 1.0.2] [ 05 ]
18+ - ` python3-venv ` and ` pip ` packages for your distro
19+
20+ Azure CLI has dropped support for Python 2.7 since version [ 2.1.0] [ 02 ] .
1821
1922## Install or update Azure CLI
2023
2124> [ !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:
25+ > These steps install Azure CLI into a ** virtual environment** under your home directory and add a
26+ > symlink to ` ~/bin/az ` . This keeps Azure CLI isolated from system Python and makes updates
27+ > straightforward.
2628
2729``` bash
28- curl -L https://aka.ms/InstallAzureCli | bash
30+ # Create and activate a virtual environment
31+ python3 -m venv ~ /lib/azure-cli
32+ source ~ /lib/azure-cli/bin/activate
33+
34+ # Upgrade pip and install (or update) Azure CLI
35+ python -m pip install --upgrade pip
36+ pip install --upgrade azure-cli
37+
38+ # Expose 'az' on your PATH via a user bin folder
39+ mkdir -p ~ /bin
40+ ln -sf ~ /lib/azure-cli/bin/az ~ /bin/az
41+
42+ # Ensure ~/bin is on PATH for future shells
43+ grep -q ' export PATH="$HOME/bin:$PATH"' ~ /.bashrc || echo ' export PATH="$HOME/bin:$PATH"' >> ~ /.bashrc
44+
45+ # Refresh shell command cache (bash/zsh)
46+ hash -r
2947```
3048
31- The script can also be downloaded and run locally. You may have to restart your shell for the
32- changes to take effect.
49+ > [ !NOTE]
50+ > If you're using zsh, replace ` .bashrc ` with ` .zshrc ` in the PATH update command so the change
51+ applies to future zsh sessions.
3352
34- ## Uninstall Azure CLI
53+ - To update later:
3554
36- [ !INCLUDE [ uninstall-boilerplate.md] ( uninstall-boilerplate.md )]
55+ ``` bash
56+ source ~ /lib/azure-cli/bin/activate
57+ pip install --upgrade azure-cli
58+ hash -r
59+ ```
3760
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).
61+ ## Uninstall Azure CLI
4062
41- 1 . Remove the installed CLI files .
63+ 1 . Remove the virtual environment and symlink .
4264
4365 ``` bash
44- rm -r < install location > /lib/azure-cli
45- rm < install location > /bin/az
66+ rm -rf ~ /lib/azure-cli
67+ rm -f ~ /bin/az
4668 ```
4769
48- 1 . Modify your ` $HOME/.bash_profile ` file to remove the following line :
70+ 1 . (Optional) Remove the PATH line from your shell profile if you added it :
4971
5072 ``` text
51- <install location>/lib/azure-cli/az.completion
73+ export PATH="$HOME/bin:$PATH"
5274 ```
5375
54- 1 . If using ` bash ` or ` zsh ` , reload your shell's command cache.
76+ 1 . Refresh the shell command cache:
5577
5678 ``` bash
5779 hash -r
@@ -66,48 +88,23 @@ installation. The default install location is the user's home directory ($HOME).
6688Here are some common problems seen during a manual installation. If you experience a problem not
6789covered here, [ file an issue on GitHub] [ 03 ] .
6890
69- ### Install without Python 3
91+ - ** ` az: command not found ` **
7092
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.
93+ - Make sure ` ~/bin ` is on your ` PATH ` (` echo $PATH ` ), the symlink exists (` ls -l ~/bin/az ` ), then
94+ ` hash -r ` and reopen your shell.
7495
75- ### curl "Object Moved" error
76-
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- ```
83-
84- ### ` az ` command not found
85-
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- ```
96+ - ** SSL/crypto errors**
9997
100- ### Proxy blocks connection
98+ - Ensure OpenSSL and libffi are installed for your distro and that your Python build links against
99+ them.
101100
102- [ !INCLUDE [ configure-proxy ] ( configure-proxy.md )]
101+ - ** Proxy issues **
103102
104- In order to get the installation scripts, your proxy needs to allow HTTPS connections to the
105- following addresses:
103+ - Configure pip or environment variables (for example, ` HTTPS_PROXY ` ) and allow access to:
106104
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
105+ - ` https://pypi.org/ `
106+ - ` https://files.pythonhosted.org/ `
107+ - Any endpoints used by your distro's package manager (for Python/venv prerequisites)
111108
112109[ !INCLUDE[ troubleshoot-wsl.md] ( troubleshoot-wsl.md )]
113110
0 commit comments