Skip to content

Latest commit

 

History

History
229 lines (162 loc) · 6.54 KB

File metadata and controls

229 lines (162 loc) · 6.54 KB
ms.topic include
ms.custom devx-track-azurecli, linux-related-content

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.

  • 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. For RHEL 10 and CentOS Stream 10,

    sudo rpm --import https://packages.microsoft.com/keys/microsoft-2025.asc

    For lower versions, use the following command:

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

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

    For CentOS Stream 10, add packages-microsoft-com-prod repository:

    sudo dnf install -y https://packages.microsoft.com/config/centos/10/packages-microsoft-prod.rpm

    For RHEL 9 or CentOS Stream 9, 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

[!INCLUDE az-upgrade]

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

sudo dnf update azure-cli

Uninstall Azure CLI

[!INCLUDE uninstall-boilerplate.md]

  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

[!INCLUDE remove-data-boilerplate.md]

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

[!INCLUDEconfigure-proxy]

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

[!INCLUDEtroubleshoot-wsl.md]