Skip to content

Latest commit

 

History

History
216 lines (146 loc) · 8.37 KB

cli-install-linux-apt.md

File metadata and controls

216 lines (146 loc) · 8.37 KB
author ms.author manager ms.date ms.topic ms.custom
chasecrum
chasecrum
mamccrea
12/19/2022
include
devx-track-azurecli

Overview

The apt package manager contains x86_64 and ARM64 packages for the Azure CLI that has been tested on the following distributions. There is no ARM64 package for Ubuntu 18.04.

Distribution Version
Ubuntu 18.04 LTS (Bionic Beaver), 20.04 LTS (Focal Fossa), 22.04 (Jammy Jellyfish)
Debian 10 (Buster), 11 (Bullseye)

Warning

You may continue to use historical versions of Azure CLI on old systems, but there will be no updates or bugfixes. Consider upgrading to newer versions of Ubuntu or Debian to use the latest Azure CLI.

Warning

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. See Ubuntu package management or ask ubuntu for more information on apt remove.

Note

The azure-cli package supports ARM64 architecture from 2.46.0.

Installation Options

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

Option 1: Install with one command

The Azure CLI team maintains a script to run 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, simply 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 install process:

    sudo apt-get update
    sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg
  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_REPO=$(lsb_release -cs)
    echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" |
        sudo tee /etc/apt/sources.list.d/azure-cli.list
  4. Update repository information and install the azure-cli package:

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

Installing a specific version

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

  1. To view available versions with command:

    apt-cache policy azure-cli
  2. To install specific version:

    sudo apt-get install azure-cli=<version>-1~bullseye

Troubleshooting

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

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. Please 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 does not 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 with regards to future versions of dependencies and rely 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 do this, 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 bullseye repository:

AZ_REPO="bullseye"

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.list and change hera main to bionic main.

Original file contents:

deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ hera main

Modified file contents

deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ bionic main

Proxy blocks connection

[!INCLUDEconfigure-proxy]

You may also want to explicitly configure apt to use this proxy at all times. 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 does not 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

[!INCLUDEtroubleshoot-wsl.md]

Update

[!INCLUDE az-upgrade]

You can also use apt-get upgrade to update the CLI package.

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

Note

This command upgrades all of the installed packages on your system that have not had a dependency change. To upgrade the CLI only, use apt-get install.

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

Uninstall

[!INCLUDE uninstall-boilerplate.md]

  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.list
  3. If you are not using other packages from Microsoft, remove the signing key:

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

    sudo apt autoremove