Muokkaa

Jaa


Install the Azure CLI on Linux

This article explains how to install the Azure CLI on Linux. Select the appropriate package manager for your distribution from the options at the top of the page. Using a Linux distribution's package manager is recommended, but you may manually install the Azure CLI on Linux by selecting the Install script option.

The current version of the Azure CLI is 2.65.0. For information about the latest release, see the release notes. To find your installed version and see if you need to update, run az version.

Before you begin

  • Azure CLI 2.38.2 (released on June 21, 2024) is the last version supported on RHEL 7 and Centos 7. Microsoft is no longer providing updates or bug fixes for these distributions.

  • Microsoft continues to develop and support Azure CLI and the Linux Install script.

  • Use the yum package manager if you're using a Linux system that doesn't support the dnf package manager.

Install Azure CLI

To install the Azure CLI, follow these steps:

  1. Import the Microsoft repository key.

    sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
    
  2. For RHEL 9 or CentOS Stream, add packages-microsoft-com-prod repository:

    sudo dnf install -y https://packages.microsoft.com/config/rhel/9.0/packages-microsoft-prod.rpm
    

    For RHEL 8, add packages-microsoft-com-prod repository:

    sudo dnf install -y https://packages.microsoft.com/config/rhel/8/packages-microsoft-prod.rpm
    

    For RHEL 7, add azure-cli repository:

    echo -e "[azure-cli]
    name=Azure CLI
    baseurl=https://packages.microsoft.com/yumrepos/azure-cli
    enabled=1
    gpgcheck=1
    gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/azure-cli.repo
    

    Caution

    CentOS 7 End Of Life (EOL) was June 30, 2024. For information on Azure CLI supported environments, see Azure CLI support lifecycle

  3. Install with the dnf install command.

    sudo dnf install azure-cli
    

Install specific version

You must first configure azure-cli repository information as shown previously. Available versions can be found at Azure CLI release notes.

  1. To view available versions with command:

    dnf list --showduplicates azure-cli
    
  2. To install a specific version:

    sudo dnf install azure-cli-<version>-1.el7
    

Update Azure CLI

Beginning with version 2.11.0, the Azure CLI provides an in-tool command to update to the latest version.

az upgrade

This command also updates all installed extensions by default. For more az upgrade options, see the command reference page. For Azure CLI versions prior to 2.11.0, update by reinstalling as described in Install the Azure CLI.

You can also update the Azure CLI with the dnf update command.

sudo dnf update azure-cli

Uninstall Azure CLI

If you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use the az feedback command to let us know what could be improved or fixed. Our goal is to make the Azure CLI bug-free and user-friendly. If you found a bug, we'd appreciate it if you file a GitHub issue.

  1. Remove the package from your system.

    sudo dnf remove azure-cli
    
  2. If you don't plan to reinstall the CLI, remove the repository information.

    sudo rm /etc/yum.repos.d/azure-cli.repo
    
  3. If you don't use any other Microsoft packages, remove the signing key.

    MSFT_KEY=`rpm -qa gpg-pubkey /* --qf "%{version}-%{release} %{summary}\n" | grep Microsoft | awk '{print $1}'`
    sudo rpm -e --allmatches gpg-pubkey-$MSFT_KEY
    

Remove data

If you don't plan to reinstall Azure CLI, remove its data.

rm -rf ~/.azure

Troubleshooting

Here are some common problems seen when installing with dnf. If you experience a problem not covered here, file an issue on GitHub.

Install on RHEL 7.6 or other systems without Python 3

If you're able, upgrade your system to a version with official support for python 3.6+ package. Otherwise, you need to first install a python3 package, then install Azure CLI without dependency.

You can use the following command to download and install the Azure CLI install script with python 3.6 built from source:

curl -sL https://azurecliprod.blob.core.windows.net/rhel7_6_install.sh | sudo bash

You can also do it step by step:

First, Azure CLI requires SSL 1.1+ and you need to build openssl 1.1 from source before building python3:

sudo dnf install gcc gcc-c++ make ncurses patch wget tar zlib zlib-devel -y
# build openssl from source
cd ~
wget https://www.openssl.org/source/openssl-1.1.1d.tar.gz
tar -xzf openssl-1.1.1d.tar.gz
cd openssl-1.1.1d
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl
make
sudo make install
# configure shared object lookup directory so that libssl.so.1.1 can be found
echo "/usr/local/ssl/lib" | sudo tee /etc/ld.so.conf.d/openssl-1.1.1d.conf
# reload config
sudo ldconfig -v

Then build Python 3 from source:

PYTHON_VERSION="3.6.9"
PYTHON_SRC_DIR=$(mktemp -d)
wget -qO- https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz | tar -xz -C "$PYTHON_SRC_DIR"
cd $PYTHON_SRC_DIR/Python-$PYTHON_VERSION
./configure --prefix=/usr --with-openssl=/usr/local/ssl
make
sudo make install

Finally, follow steps 1 and 2 of the install instruction to add the Azure CLI repository. You can now download the package and install it without dependency.

Note

If the dnf download plugin isn't already installed, you will encounter a command not found error when executing the following code. Use dnf install 'dnf-command(download)' to install the dnf download plugin.

sudo dnf download azure-cli
sudo rpm -ivh --nodeps azure-cli-*.rpm

As an alternative, you can also install Python 3 using another repo. Use this method, if you have set up python3 but are still getting the error python3: command not found. Make sure it has been included it in your path.

scl enable rh-python36 bash

Proxy blocks connection

If you're unable to connect to an external resource due to a proxy, make sure that you've correctly set the HTTP_PROXY and HTTPS_PROXY variables in your shell. You need to contact your system administrator to know what host(s) and port(s) to use for these proxies.

The values in these variables are used by many Linux programs, and during the install process. To set these values:

# No auth
export HTTP_PROXY=http://[proxy]:[port]
export HTTPS_PROXY=https://[proxy]:[port]

# Basic auth
export HTTP_PROXY=http://[username]:[password]@[proxy]:[port]
export HTTPS_PROXY=https://[username]:[password]@[proxy]:[port]

Important

If you are behind a proxy, these shell variables must be set to connect to Azure services with the CLI. If you are not using basic auth, it's recommended to export these variables in your .bashrc file. Always follow your business' security policies and the requirements of your system administrator.

You may also want to explicitly configure dnf to always use this proxy. Make sure that the following lines appear under the [main] section of /etc/dnf/dnf.conf:

[main]
# ...
proxy=http://[proxy]:[port] # If your proxy requires https, change http->https
proxy_username=[username] # Only required for basic auth
proxy_password=[password] # Only required for basic auth

In order to get the Microsoft signing key and the package from our repository, your proxy needs to allow HTTPS connections to the following address:

  • https://packages.microsoft.com

CLI fails to install or run on Windows Subsystem for Linux

Since Windows Subsystem for Linux (WSL) is a system call translation layer on top of the Windows platform, you might experience an error when trying to install or run the Azure CLI. The CLI relies on some features that may have a bug in WSL. If you experience an error no matter how you install the CLI, there's a good chance it's an issue with WSL and not with the CLI install process.

To troubleshoot your WSL installation and possibly resolve issues:

  • If you can, run an identical install process on a Linux machine or VM to see if it succeeds. If it does, your issue is likely related to WSL. To start a Linux VM in Azure, see the create a Linux VM in the Azure portal documentation.
  • Make sure that you're running the latest version of WSL. To get the latest version, update your Windows 10 installation.
  • Check for any open issues with WSL that might address your problem. Often there are suggestions on how to work around the problem, or information about a release where the issue is fixed.
  • If there are no existing issues for your problem, file a new issue with WSL and make sure that you include as much information as possible.

If you continue to have issues installing or running on WSL, consider installing the CLI for Windows.

Before you begin

  • Azure CLI 2.38.2 (released on June 21, 2024) is the latest version supported on SUSE Linux Enterprise Server (SLES) and OpenSUSE (Leap). Microsoft is no longer providing updates or bug fixes for these distributions.

  • Microsoft continues to develop and support the Azure CLI and the Linux Install script. SUSE maintains and supports packages provided by SUSE/OpenSUSE repositories.

  • In Azure, SUSE and OpenSUSE virtual machines (VMs) based on Azure Marketplace images already have the Azure CLI installed.

Install Azure CLI

To install Azure CLI on SUSE/OpenSUSE, choose one of the following methods:

  1. Use the Enterprise package provided by SUSE in the SUSE/OpenSUSE repositories.

  2. Use the installation method described in the “Install script (any)” tab.

  3. Install from Microsoft repositories

Install from SUSE or OpenSUSE repositories

The RPM package of the Azure CLI depends on the python3 package.

sudo zypper install -y azure-cli

Install with the install script

You can manually install the Azure CLI on any version of Linux by using the Install script option.

If you're updating to the most recent version using this method, be sure to uninstall the previous version first, and any repositories you may have added for that version.

Install from Microsoft repositories

To install the most recent historical version of the Azure CLI using Microsoft repositories, follow these steps.

(This package has been tested with SLES 15 and OpenSUSE Leap 15.1)

  1. Install curl:

    sudo zypper install -y curl
    
  2. Import the Microsoft repository key:

    sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
    
  3. Create local azure-cli repository information:

    sudo zypper addrepo --name 'Azure CLI' --check https://packages.microsoft.com/yumrepos/azure-cli azure-cli
    
  4. Update the zypper package index and install:

    sudo zypper install --from azure-cli azure-cli
    

    Input 2 to continue install by ignoring some of its dependencies.

Install specific version

You must first configure azure-cli repository information as shown previously. Available versions can be found in the Azure CLI release notes.

  1. View the available versions using this command:

    zypper search --details --match-exact azure-cli
    
  2. To install a specific version:

    sudo zypper install --from azure-cli azure-cli=<version>-1.el7
    

Update Azure CLI

Beginning with version 2.11.0, the Azure CLI provides an in-tool command to update to the latest version.

az upgrade

This command also updates all installed extensions by default. For more az upgrade options, see the command reference page. For Azure CLI versions prior to 2.11.0, update by reinstalling as described in Install the Azure CLI.

You can also update the package with the zypper update command.

sudo zypper refresh
sudo zypper update azure-cli

Uninstall Azure CLI

If you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use the az feedback command to let us know what could be improved or fixed. Our goal is to make the Azure CLI bug-free and user-friendly. If you found a bug, we'd appreciate it if you file a GitHub issue.

  1. Remove the package from your system.

    sudo zypper remove -y azure-cli
    
  2. If you don't plan to reinstall the CLI, remove the repository information.

    sudo zypper removerepo azure-cli
    
  3. If you don't use other Microsoft packages, remove the Microsoft signing key.

    MSFT_KEY=`rpm -qa gpg-pubkey /* --qf "%{version}-%{release} %{summary}\n" | grep Microsoft | awk '{print $1}'`
    sudo rpm -e --allmatches gpg-pubkey-$MSFT_KEY
    

Remove data

If you don't plan to reinstall Azure CLI, remove its data.

rm -rf ~/.azure

Troubleshooting

Here are some common problems seen when installing with zypper. If you experience a problem not covered here, file an issue on GitHub.

Install without Python 3

Important

The RPM package of the Azure CLI depends on the python3 package. On your system, this may be a Python version which predates the requirement of Python 3.6.x. If this affects you, find a replacement python3 package.

Be aware that Python 2 has reached end of life (EOL) on January 1, 2020, and will no longer receive updates. Azure CLI has dropped support for Python 2.7 since version 2.1.0. Newer versions of the CLI may not run correctly using Python 2.7.

NotImplementedError on OpenSUSE 15 VM

The OpenSUSE 15 VM has a preinstalled Azure CLI with version 2.0.45, which is outdated and has issues with az login. Remove this version along with its dependencies before following the Install instruction to add the latest Azure CLI:

sudo zypper rm -y --clean-deps azure-cli

If you updated the Azure CLI without removing the dependencies of version 2.0.45, its old dependencies may affect the latest version of the Azure CLI. You need to add back the old version to link to its dependencies and then remove azure-cli along with its dependencies:

# The package name may vary on different system version, run 'zypper --no-refresh info azure-cli' to check the source package format
sudo zypper install --oldpackage azure-cli-2.0.45-4.22.noarch

sudo zypper rm -y --clean-deps azure-cli

Install on SLES 12 or other systems without Python 3.6

On SLES 12, the default python3 package is 3.4 and not supported by Azure CLI. You can first follow step 1-3 of the install instruction to add the azure-cli repository. Then build a higher version python3 from source. Finally, you can download the Azure CLI package and install it without dependency.

You can use the following one command to install or update Azure CLI based on above steps. The script installs Python 3.8 under /usr/local/azcli and makes Azure CLI use it by setting an alias of az to PATH=/usr/local/azcli/bin:$PATH az. You can also download the script and modify it according to your needs. For instance, you can change the Python version or install location.

curl -sL https://azurecliprod.blob.core.windows.net/sles12_install_v2.sh | sudo bash

For the first time install, remember to run the following command to activate the alias:

source ~/.bashrc

Proxy blocks connection

If you're unable to connect to an external resource due to a proxy, make sure that you've correctly set the HTTP_PROXY and HTTPS_PROXY variables in your shell. You need to contact your system administrator to know what host(s) and port(s) to use for these proxies.

The values in these variables are used by many Linux programs, and during the install process. To set these values:

# No auth
export HTTP_PROXY=http://[proxy]:[port]
export HTTPS_PROXY=https://[proxy]:[port]

# Basic auth
export HTTP_PROXY=http://[username]:[password]@[proxy]:[port]
export HTTPS_PROXY=https://[username]:[password]@[proxy]:[port]

Important

If you are behind a proxy, these shell variables must be set to connect to Azure services with the CLI. If you are not using basic auth, it's recommended to export these variables in your .bashrc file. Always follow your business' security policies and the requirements of your system administrator.

You may also want to explicitly configure zypper (via yast2) to always use this proxy. To do so, run the yast2 proxy command as superuser, and fill in the information presented in the form. If you have a window manager available on your system, you can also use the Network Services > Proxy pane in the YaST Control Center.

For advanced configuration or more information, see the OpenSUSE Proxy configuration documentation

To get the Microsoft signing key and get the package from our repository, your proxy needs to allow HTTPS connections to the following addresses:

  • https://packages.microsoft.com
  • https://download.opensuse.org

CLI fails to install or run on Windows Subsystem for Linux

Since Windows Subsystem for Linux (WSL) is a system call translation layer on top of the Windows platform, you might experience an error when trying to install or run the Azure CLI. The CLI relies on some features that may have a bug in WSL. If you experience an error no matter how you install the CLI, there's a good chance it's an issue with WSL and not with the CLI install process.

To troubleshoot your WSL installation and possibly resolve issues:

  • If you can, run an identical install process on a Linux machine or VM to see if it succeeds. If it does, your issue is likely related to WSL. To start a Linux VM in Azure, see the create a Linux VM in the Azure portal documentation.
  • Make sure that you're running the latest version of WSL. To get the latest version, update your Windows 10 installation.
  • Check for any open issues with WSL that might address your problem. Often there are suggestions on how to work around the problem, or information about a release where the issue is fixed.
  • If there are no existing issues for your problem, file a new issue with WSL and make sure that you include as much information as possible.

If you continue to have issues installing or running on WSL, consider installing the CLI for Windows.

SSL certificate problem

When a certificate is broken or outdated on a machine, you might receive an error indicating that curl failed to verify the legitimacy of the server, and therefore couldn't establish a secure connection. Update your certificate to correct the problem.

sudo zypper update-ca-certificates

Before you begin

  • The apt package manager contains x86_64 and ARM64 packages for the Azure CLI that has been tested on the following distributions.

    Distribution Version
    Ubuntu 20.04 LTS (Focal Fossa), 22.04 (Jammy Jellyfish), 24.04 (Noble Numbat)
    Debian 11 (Bullseye), 12 (Bookworm)
  • Ubuntu 20.04 (Focal Fossa) and 20.10 (Groovy Gorilla) include an azure-cli package with version 2.0.81 provided by the universe repository. This package is outdated and not recommended. If this package is installed, remove the package before continuing by running the command sudo apt remove azure-cli -y && sudo apt autoremove -y. For more information on apt remove, see the Ubuntu package management or ask ubuntu.

Install Azure CLI

There are two options to install the Azure CLI on your system. You can download an install script that runs the install commands for you, or you can execute the install commands yourself in a step-by-step process. Both methods are provided here:

Option 1: Install with one command

The easiest way to install the Azure CLI is through a script maintained by the Azure CLI team. This script runs all installation commands in one step. This script is downloaded via curl and piped directly to bash to install the CLI.

If you wish to inspect the contents of the script yourself before executing, download the script first using curl and inspect it in your favorite text editor.

curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

Option 2: Step-by-step installation instructions

If you prefer a step-by-step installation process, complete the following steps to install the Azure CLI.

  1. Get packages needed for the installation process:

    sudo apt-get update
    sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
    
  2. Download and install the Microsoft signing key:

    sudo mkdir -p /etc/apt/keyrings
    curl -sLS https://packages.microsoft.com/keys/microsoft.asc |
      gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null
    sudo chmod go+r /etc/apt/keyrings/microsoft.gpg
    
  3. Add the Azure CLI software repository:
    AZ_DIST=$(lsb_release -cs)
    echo "Types: deb
    URIs: https://packages.microsoft.com/repos/azure-cli/
    Suites: ${AZ_DIST}
    Components: main
    Architectures: $(dpkg --print-architecture)
    Signed-by: /etc/apt/keyrings/microsoft.gpg" | sudo tee /etc/apt/sources.list.d/azure-cli.sources
    
  4. Update repository information and install the azure-cli package:

    sudo apt-get update
    sudo apt-get install azure-cli
    

Install specific version

Configure the azure-cli repository information as shown previously. Available versions can be found at Azure CLI release notes.

  1. View available versions of the Azure CLI.

    apt-cache policy azure-cli
    
  2. Install a specific version.

    # Obtain the currently installed distribution
    AZ_DIST=$(lsb_release -cs)
    
    # Store an Azure CLI version of choice
    AZ_VER=2.51.0
    
    # Install a specific version
    sudo apt-get install azure-cli=${AZ_VER}-1~${AZ_DIST}
    

    To install a specific version without variables, replace the Azure CLI version and Linux distribution name shown:

    sudo apt-get install azure-cli=2.51.0-1~bullseye
    

If you receive error message Unable to locate package azure-cli, the azure-cli repository information is not configured. Follow the steps given in Option 2: Step-by-step installation instructions.

If you receive error message Version x.xx.x-1~distributionName for azure-cli was not found, use lsb_release -cs to find the distribution you're running.

Update Azure CLI

Beginning with version 2.11.0, the Azure CLI provides an in-tool command to update to the latest version.

az upgrade

This command also updates all installed extensions by default. For more az upgrade options, see the command reference page. For Azure CLI versions prior to 2.11.0, update by reinstalling as described in Install the Azure CLI.

You can also use apt-get upgrade to update the CLI package. This command upgrades all of the installed packages on your system that haven't had a dependency change.

sudo apt-get update && sudo apt-get upgrade

To upgrade the CLI only, use apt-get install.

sudo apt-get update && sudo apt-get install --only-upgrade -y azure-cli

Uninstall Azure CLI

If you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use the az feedback command to let us know what could be improved or fixed. Our goal is to make the Azure CLI bug-free and user-friendly. If you found a bug, we'd appreciate it if you file a GitHub issue.

  1. Uninstall with apt-get remove:

    sudo apt-get remove -y azure-cli
    
  2. If you don't plan to reinstall the CLI, remove the Azure CLI repository information:

    sudo rm /etc/apt/sources.list.d/azure-cli.sources
    
  3. If you aren't using other packages from Microsoft, remove the signing key:

    sudo rm /etc/apt/keyrings/microsoft.gpg
    
  4. Remove any unneeded packages:

    sudo apt autoremove
    

Remove data

If you don't plan to reinstall Azure CLI, remove its data.

rm -rf ~/.azure

Troubleshooting

Here are some common problems seen when installing with apt. If you experience a problem not covered here, file an issue on GitHub.

The azure-cli package supports ARM64 architecture from CLI version 2.46.0.

No module issue on Ubuntu 20.04 (Focal)/WSL

If you installed azure-cli on Focal without adding the Azure CLI software repository in step 3 of the manual install instructions or using our script, you may encounter issues such as no module named 'decorator' or 'antlr4' as the package you installed is the outdated azure-cli 2.0.81 from the focal/universe repository. Remove it first by running sudo apt remove azure-cli -y && sudo apt autoremove -y, then follow the above instructions to install the latest azure-cli package.

lsb_release doesn't return the correct base distribution version

Some Ubuntu or other Debian-derived distributions (such as Linux Mint) may not return the correct version name from lsb_release. This value is used in the install process to determine the package to install. If you know the code name of the Ubuntu or Debian version that your distribution is derived from, you can set the AZ_REPO value manually when adding the repository. Otherwise, look up information for your distribution on how to determine the base distribution code name and set AZ_REPO to the correct value.

No package for your distribution

Sometimes, an updated Azure CLI package isn't immediately available following a distribution version release. The Azure CLI is designed to be resilient to future versions of dependencies and relies on as few of them as possible. If there's no package available for your base distribution, try a package for an earlier distribution.

To try a package for an earlier distribution, set the value of AZ_REPO manually when adding the repository. For Ubuntu distributions, use the latest jammy repository:

AZ_REPO="jammy"

For Debian distributions, use the latest bookworm repository:

AZ_REPO="bookworm"

Important

Distributions released before Ubuntu Bionic and Debian Buster are not supported.

Elementary OS (EOS) fails to install the Azure CLI

EOS fails to install the Azure CLI because lsb_release returns HERA, which is the EOS release name. The solution is to fix the file /etc/apt/sources.list.d/azure-cli.sources and change Suites: hera to Suites: bionic.

Original file contents:

Types: deb
URIs: https://packages.microsoft.com/repos/azure-cli/
Suites: hera
Components: main
Architectures: amd64
Signed-by: /etc/apt/keyrings/microsoft.gpg

Modified file contents

Types: deb
URIs: https://packages.microsoft.com/repos/azure-cli/
Suites: bionic
Components: main
Architectures: amd64
Signed-by: /etc/apt/keyrings/microsoft.gpg

Proxy blocks connection

If you're unable to connect to an external resource due to a proxy, make sure that you've correctly set the HTTP_PROXY and HTTPS_PROXY variables in your shell. You need to contact your system administrator to know what host(s) and port(s) to use for these proxies.

The values in these variables are used by many Linux programs, and during the install process. To set these values:

# No auth
export HTTP_PROXY=http://[proxy]:[port]
export HTTPS_PROXY=https://[proxy]:[port]

# Basic auth
export HTTP_PROXY=http://[username]:[password]@[proxy]:[port]
export HTTPS_PROXY=https://[username]:[password]@[proxy]:[port]

Important

If you are behind a proxy, these shell variables must be set to connect to Azure services with the CLI. If you are not using basic auth, it's recommended to export these variables in your .bashrc file. Always follow your business' security policies and the requirements of your system administrator.

You may also want to explicitly configure apt to always use this proxy. Make sure that the following lines appear in an apt configuration file in /etc/apt/apt.conf.d/. We recommend using either your existing global configuration file, an existing proxy configuration file, 40proxies, or 99local, but follow your system administration requirements.

Acquire {
    http::proxy "http://[username]:[password]@[proxy]:[port]";
    https::proxy "https://[username]:[password]@[proxy]:[port]";
}

If your proxy doesn't use basic auth, remove the [username]:[password]@ portion of the proxy URI. If you require more information for proxy configuration, see the official Ubuntu documentation:

In order to get the Microsoft signing key and get the package from our repository, your proxy needs to allow HTTPS connections to the following address: `https://packages.microsoft.com.

CLI fails to install or run on Windows Subsystem for Linux

Since Windows Subsystem for Linux (WSL) is a system call translation layer on top of the Windows platform, you might experience an error when trying to install or run the Azure CLI. The CLI relies on some features that may have a bug in WSL. If you experience an error no matter how you install the CLI, there's a good chance it's an issue with WSL and not with the CLI install process.

To troubleshoot your WSL installation and possibly resolve issues:

  • If you can, run an identical install process on a Linux machine or VM to see if it succeeds. If it does, your issue is likely related to WSL. To start a Linux VM in Azure, see the create a Linux VM in the Azure portal documentation.
  • Make sure that you're running the latest version of WSL. To get the latest version, update your Windows 10 installation.
  • Check for any open issues with WSL that might address your problem. Often there are suggestions on how to work around the problem, or information about a release where the issue is fixed.
  • If there are no existing issues for your problem, file a new issue with WSL and make sure that you include as much information as possible.

If you continue to have issues installing or running on WSL, consider installing the CLI for Windows.

Install Azure CLI

RPMs are released for Azure Linux through CBL-Mariner. The azure-cli package supports ARM64 architecture from CLI version 2.46.0.

To install the Azure CLI, follow these steps:

  1. Install the official Microsoft curated set of trusted root certificates:

    sudo tdnf install ca-certificates
    
  2. Install Azure CLI:

    sudo tdnf install azure-cli
    

Install specific version

Available versions can be found at Azure CLI release notes.

To view available versions with command:

tdnf list azure-cli

To install specific version:

sudo tdnf install azure-cli-<version>-1

Update Azure CLI

Update the Azure CLI with the tdnf update command:

sudo tdnf update azure-cli

Uninstall Azure CLI

If you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use the az feedback command to let us know what could be improved or fixed. Our goal is to make the Azure CLI bug-free and user-friendly. If you found a bug, we'd appreciate it if you file a GitHub issue.

Remove the package from your system:

sudo tdnf remove azure-cli

Remove data

If you don't plan to reinstall Azure CLI, remove its data.

rm -rf ~/.azure

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.

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

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:

curl -L https://aka.ms/InstallAzureCli | bash

The script can also be downloaded and run locally. You may have to restart your shell for the changes to take effect.

Uninstall Azure CLI

If you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use the az feedback command to let us know what could be improved or fixed. Our goal is to make the Azure CLI bug-free and user-friendly. If you found a bug, we'd appreciate it if you file a GitHub issue.

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

  1. Remove the installed CLI files.

    rm -r <install location>/lib/azure-cli
    rm <install location>/bin/az
    
  2. Modify your $HOME/.bash_profile file to remove the following line:

    <install location>/lib/azure-cli/az.completion
    
  3. If using bash or zsh, reload your shell's command cache.

    hash -r
    

Remove data

If you don't plan to reinstall Azure CLI, remove its data.

rm -rf ~/.azure

Troubleshooting

Here are some common problems seen during a manual installation. If you experience a problem not covered here, file an issue on GitHub.

Install without Python 3

The Azure CLI has dropped support for Python 2.7 since version 2.1.0. On your system, there may be a Python version that predates the requirement of Python 3.6.x. Find a replacement python3 package.

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:

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.

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

Proxy blocks connection

If you're unable to connect to an external resource due to a proxy, make sure that you've correctly set the HTTP_PROXY and HTTPS_PROXY variables in your shell. You need to contact your system administrator to know what host(s) and port(s) to use for these proxies.

The values in these variables are used by many Linux programs, and during the install process. To set these values:

# No auth
export HTTP_PROXY=http://[proxy]:[port]
export HTTPS_PROXY=https://[proxy]:[port]

# Basic auth
export HTTP_PROXY=http://[username]:[password]@[proxy]:[port]
export HTTPS_PROXY=https://[username]:[password]@[proxy]:[port]

Important

If you are behind a proxy, these shell variables must be set to connect to Azure services with the CLI. If you are not using basic auth, it's recommended to export these variables in your .bashrc file. Always follow your business' security policies and the requirements of your system administrator.

In order to get the installation scripts, your proxy needs to allow HTTPS connections to the following addresses:

  • 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

CLI fails to install or run on Windows Subsystem for Linux

Since Windows Subsystem for Linux (WSL) is a system call translation layer on top of the Windows platform, you might experience an error when trying to install or run the Azure CLI. The CLI relies on some features that may have a bug in WSL. If you experience an error no matter how you install the CLI, there's a good chance it's an issue with WSL and not with the CLI install process.

To troubleshoot your WSL installation and possibly resolve issues:

  • If you can, run an identical install process on a Linux machine or VM to see if it succeeds. If it does, your issue is likely related to WSL. To start a Linux VM in Azure, see the create a Linux VM in the Azure portal documentation.
  • Make sure that you're running the latest version of WSL. To get the latest version, update your Windows 10 installation.
  • Check for any open issues with WSL that might address your problem. Often there are suggestions on how to work around the problem, or information about a release where the issue is fixed.
  • If there are no existing issues for your problem, file a new issue with WSL and make sure that you include as much information as possible.

If you continue to have issues installing or running on WSL, consider installing the CLI for Windows.

Next Steps

Now that you've installed the Azure CLI, take a short tour of its features and common commands.