@@ -5,53 +5,71 @@ 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.10 or higher ] [ 06 ] - For more information, see
1515 [ Support lifecycle - Python dependency] [ 01 ] .
16- - [ libffi] [ 04 ]
17- - [ OpenSSL 1.0.2] [ 05 ]
16+ - ` python3-venv ` package for your distro
1817
1918## Install or update Azure CLI
2019
2120> [ !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:
21+ > These steps install Azure CLI into a ** virtual environment** under your home directory and add a
22+ > symlink to ` ~/bin/az ` . This keeps Azure CLI isolated from system Python and makes updates
23+ > straightforward.
2624
2725``` bash
28- curl -L https://aka.ms/InstallAzureCli | bash
26+ # Create and activate a virtual environment
27+ python3 -m venv ~ /lib/azure-cli
28+ source ~ /lib/azure-cli/bin/activate
29+
30+ # Upgrade pip and install (or update) Azure CLI
31+ python -m pip install --upgrade pip
32+ pip install --upgrade azure-cli
33+
34+ # Expose 'az' on your PATH via a user bin folder
35+ mkdir -p ~ /bin
36+ ln -sf ~ /lib/azure-cli/bin/az ~ /bin/az
37+
38+ # Ensure ~/bin is on PATH for future shells
39+ grep -q ' export PATH="$HOME/bin:$PATH"' ~ /.bashrc || echo ' export PATH="$HOME/bin:$PATH"' >> ~ /.bashrc
40+
41+ # Refresh shell command cache (bash/zsh)
42+ hash -r
2943```
3044
31- The script can also be downloaded and run locally. You may have to restart your shell for the
32- changes to take effect.
45+ > [ !NOTE]
46+ > If you're using zsh, replace ` .bashrc ` with ` .zshrc ` in the PATH update command so the change
47+ applies to future zsh sessions.
3348
34- ## Uninstall Azure CLI
49+ - To update later:
3550
36- [ !INCLUDE [ uninstall-boilerplate.md] ( uninstall-boilerplate.md )]
51+ ``` bash
52+ source ~ /lib/azure-cli/bin/activate
53+ pip install --upgrade azure-cli
54+ hash -r
55+ ```
3756
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).
57+ ## Uninstall Azure CLI
4058
41- 1 . Remove the installed CLI files .
59+ 1 . Remove the virtual environment and symlink .
4260
4361 ``` bash
44- rm -r < install location > /lib/azure-cli
45- rm < install location > /bin/az
62+ rm -rf ~ /lib/azure-cli
63+ rm -f ~ /bin/az
4664 ```
4765
48- 1 . Modify your ` $HOME/.bash_profile ` file to remove the following line :
66+ 1 . (Optional) Remove the PATH line from your shell profile if you added it :
4967
5068 ``` text
51- <install location>/lib/azure-cli/az.completion
69+ export PATH="$HOME/bin:$PATH"
5270 ```
5371
54- 1 . If using ` bash ` or ` zsh ` , reload your shell's command cache.
72+ 1 . Refresh the shell command cache:
5573
5674 ``` bash
5775 hash -r
@@ -66,56 +84,20 @@ installation. The default install location is the user's home directory ($HOME).
6684Here are some common problems seen during a manual installation. If you experience a problem not
6785covered here, [ file an issue on GitHub] [ 03 ] .
6886
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
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- ```
99-
100- ### Proxy blocks connection
87+ - ** ` az: command not found ` **
10188
102- [ !INCLUDE[ configure-proxy] ( configure-proxy.md )]
89+ - Make sure ` ~/bin ` is on your ` PATH ` (` echo $PATH ` ), the symlink exists (` ls -l ~/bin/az ` ), then
90+ ` hash -r ` and reopen your shell.
10391
104- In order to get the installation scripts, your proxy needs to allow HTTPS connections to the
105- following addresses:
92+ - ** Proxy issues**
10693
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
94+ - For proxy endpoint configuration, see [ Azure CLI endpoints for proxy bypass] [ 07 ] .
11195
11296[ !INCLUDE[ troubleshoot-wsl.md] ( troubleshoot-wsl.md )]
11397
11498<!-- link references -->
11599
116100[ 01 ] : ../azure-cli-support-lifecycle.md#python-dependency
117- [ 02 ] : /cli/azure/release-notes-azure-cli#february-18-2020
118101[ 03 ] : https://github.com/Azure/azure-cli/issues
119- [ 04 ] : https://sourceware.org/libffi/
120- [ 05 ] : https://www.openssl.org/source/
121102[ 06 ] : https://www.python.org/downloads/
103+ [ 07 ] : ../azure-cli-endpoints.md
0 commit comments