azure-cli
azure-cli copied to clipboard
Unofficial Azure CLI deb packages are distributed by Linux repositories
Community packagers release unofficial Azure CLI deb packages on multiple Linux repositories. These packages are not maintained by Microsoft, outdated, and contain various bugs.
Ubuntu
2.0.81 for Focal 20.04
Package: https://packages.ubuntu.com/source/focal/azure-cli Issues: https://github.com/Azure/azure-cli/issues?q=is%3Aissue+2.0.81
2.18.0 for Hirsute 21.04
Package: https://packages.ubuntu.com/hirsute/python3-azure-cli Issues: https://github.com/Azure/azure-cli/issues?q=is%3Aissue+2.18.0
Debian
2.18.0 for Bullseye 11
Package: https://packages.debian.org/bullseye/azure-cli Issues: https://github.com/Azure/azure-cli/issues?q=is%3Aissue+2.18.0
2.37.0 for sid (unstable)
Package: https://packages.debian.org/sid/azure-cli
How unofficial Azure CLI is installed
Ubuntu 20.04 Focal, Debian 11 Bullseye
The user doesn't follow the Install the Azure CLI on Linux official document to add Microsoft Linux Repo (https://packages.microsoft.com/repos/azure-cli/) to apt. apt install azure-cli will install the above unofficial ones from Debian/Ubuntu repo.
Debian sid
Even though the user added Microsoft Linux Repo (https://packages.microsoft.com/repos/azure-cli/) to apt, apt update fails because we don't release deb package for Debian sid:
# AZ_REPO=$(lsb_release -cs)
# echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | tee /etc/apt/sources.list.d/azure-cli.list
# echo $AZ_REPO
sid
# apt update
Hit:1 http://deb.debian.org/debian sid InRelease
Ign:2 https://packages.microsoft.com/repos/azure-cli sid InRelease
Err:3 https://packages.microsoft.com/repos/azure-cli sid Release
404 Not Found [IP: 20.188.102.6 443]
Reading package lists... Done
E: The repository 'https://packages.microsoft.com/repos/azure-cli sid Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
apt install azure-cli will install the unofficial 2.37.0.
https://packages.microsoft.com/ is the ONLY source where official Azure CLI packages are distributed.
Install official Azure CLI
To install the latest official Azure CLI, please follow the official document: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt
Uninstall unofficial Azure CLI
If you have already installed the unofficial Azure CLI, you may uninstall it first with
sudo apt remove azure-cli --yes && sudo apt autoremove --yes
In a docker container:
apt remove azure-cli -y && apt autoremove -y
Then install from the official source.
On debian testing, when I'm using the automated installed (curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash), it still installs the debian package, because it has a newer version (official is 2.30.0-1~buster, while debian is 2.30.0-2).
#20557
Azure CLI on Debian sid
@bluca, I noticed that recently you have published azure-cli (2.33.0-2) for Debian sid: https://packages.debian.org/sid/azure-cli

This makes it impossible to install official Azure CLI 2.33.0 from https://packages.microsoft.com/repos/azure-cli/
What is the best way to install official Azure CLI from https://packages.microsoft.com/repos/azure-cli/ , instead of Debian's repo?
[Outdated] How to tell if the installed Azure CLI is official
An unofficial Azure CLI will show info like this (from https://github.com/Azure/azure-cli/issues/21254):
Linux-5.15.0-3-amd64-x86_64-with-glibc2.33, Debian GNU/Linux bookworm/sid
Python 3.9.10
Installer: DEB
We can tell this is not an Azure CLI deb package released by Microsoft, because the official Azure CLI deb package doesn't bundle Python 3.9.10. Instead, the bundled Python in the official deb package is currently 3.6.10. (We are working on moving to Python 3.8 in https://github.com/Azure/azure-cli/pull/20869.)
How to tell if the installed Azure CLI is unofficial
An unofficial Azure CLI has dist-packages in its call stack (https://github.com/Azure/azure-cli/issues/22546):
The command failed with an unexpected error. Here is the traceback:
'RoleDefinitionsOperations' object has no attribute 'config'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/__init__.py", line 658, in execute
raise ex
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/__init__.py", line 721, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/__init__.py", line 692, in _run_job
result = cmd_copy(params)
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
return self.handler(*args, **kwargs)
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/usr/lib/python3/dist-packages/azure/cli/command_modules/role/custom.py", line 49, in list_role_definitions
definitions_client.config.subscription_id)
AttributeError: 'RoleDefinitionsOperations' object has no attribute 'config'
dist-packages is Ubuntu Python's equivalent location of the official Python's site-packages.
The official Azure CLI's site-packages is at
/opt/az/lib/python3.10/site-packages
The unofficial packages 2.0.81 and 2.18.0 on Ubuntu repo also contain bugs that make keyvault commands fail (https://github.com/Azure/azure-cli/issues/13101):
az keyvault secret show
Errors:
No module named 'azure.keyvault.v7_0'
Traceback (most recent call last):
python3/dist-packages/knack/cli.py, ln 206, in invoke
cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 528, in execute
self.commands_loader.load_arguments(command)
azure/cli/core/__init__.py, ln 299, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
...
<frozen importlib._bootstrap>, ln 1014, in _gcd_import
<frozen importlib._bootstrap>, ln 991, in _find_and_load
<frozen importlib._bootstrap>, ln 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'azure.keyvault.v7_0'
Possible solutions
- Remove the alias
azure-clifrom https://packages.debian.org/sid/azure-cli, and only use the namepython3-azure-cliso that it can be distinguished from Microsoft'sazure-cli. - Pull down the package
azure-clifrom Debian/Ubuntu repo https://packages.debian.org/sid/azure-cli. - Force installing from
packages.microsoft.com: https://github.com/Azure/azure-cli/pull/20557
Possible solutions
1. Remove the alias `azure-cli` from https://packages.debian.org/sid/azure-cli, and only use the name `python3-azure-cli` so that it can be distinguished from Microsoft's `azure-cli`. 2. Pull down the package `azure-cli` from Debian/Ubuntu repo https://packages.debian.org/sid/azure-cli. 3. Force installing from `packages.microsoft.com`: [{Packaging} Prioritize official package over the dist one #20557](https://github.com/Azure/azure-cli/pull/20557)
Please consider this soon, deb upgrade overwrites the microsoft distributed one with the broken one unless you freeze/hold the package, which is unexpected and not novice friendly.
Thanks everybody for your time in this project, I really appreaciate it.
I'm not able to get installed the official packages in debian.
Steps to reproduce
- Uninstall
sudo apt remove azure-cli -y && sudo apt autoremove -y
sudo rm -fr sudo rm -fr /etc/apt/sources.list.d/zure-cli.list
- Install
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- Display version
az --version | grep "Extensions system"
Expected behaviour
See "site-packages' in the path (as per https://github.com/Azure/azure-cli/issues/23990#issuecomment-1272255697)
Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'
Found behaviour
Extensions system directory '/usr/lib/python3/dist-packages/azure-cli-extensions'
Errors
None
@jlegido Looks like you're still installing azure-cli from Debian sid. (jiasli has explained above) You need an extra step, run this and check again.
echo 'Package: azure-cli
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001' | sudo tee /etc/apt/preferences.d/azure-cli
sudo apt update & sudo apt install azure-cli
@bebound @jiasli thanks for your assistance, below commands are the ones that worked for me:
sudo apt remove azure-cli -y && sudo apt autoremove -y
sudo rm -fr sudo rm -fr /etc/apt/sources.list.d/zure-cli.list
echo 'Package: azure-cli
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001' | sudo tee /etc/apt/preferences.d/azure-cli
sudo apt update & sudo apt install azure-cli
To be honest official installation guide should be updated, since none of proposed ways works currently.
IMHO you really should cooperate with proper packagers, and instead of pushing back to whoever reports bugs from the package in the debian archive, try to understand them.
Embedding a whole python 3.10 interpreter full of even the interpreter test data in a single arch:all (!) debian package is… hard to see.
I think maybe someone should start the process of removing the debian azure-cli package from the debian repositories entirely if MS isn't willing to work with them.
IMHO you really should cooperate with proper packagers, and instead of pushing back to whoever reports bugs from the package in the debian archive, try to understand them.
Unfortunately, the debian archive maintainer is pretty much entirely inactive.
Embedding a whole python 3.10 interpreter full of even the interpreter test data in a single arch:all (!) debian package is… hard to see.
Incredibly dismaying, but the art of making proper debian packages is a lost one. Virtual environments (pyenv, docker, etc) have only accelerated this decay, as the competency to do proper dependency management is pretty much non-existent now.
Debian bookworm now has unofficial Azure CLI 2.43.0 released:
https://packages.debian.org/bookworm/azure-cli

This causes issue https://github.com/Azure/azure-cli/issues/24959.
Debian sid now has unofficial Azure CLI 2.44.1 released:
https://packages.debian.org/sid/azure-cli

Possible solutions
1. Remove the alias `azure-cli` from https://packages.debian.org/sid/azure-cli, and only use the name `python3-azure-cli` so that it can be distinguished from Microsoft's `azure-cli`.
That is not the same package. azure-cli contains the command line client, while python3-azure-cli contains only the Python modules. If Microsoft has packaged azcli differently, you've been doing it wrong. There are very good reasons to separate applications from libraries, and there are standard Debian policies around packaging Python modules: https://www.debian.org/doc/packaging-manuals/python-policy/
2. Pull down the package `azure-cli` from Debian/Ubuntu repo https://packages.debian.org/sid/azure-cli.
That will make installation more complicated for novice users (add custom repo, etc.). It's better if you work with package maintainers to reach a common standard for packaging azcli on different distributions.
Another option would be to name the packages differently, to avoid confusion.
3. Force installing from `packages.microsoft.com`: [{Packaging} Prioritize official package over the dist one #20557](https://github.com/Azure/azure-cli/pull/20557)
That is the only "real" solution for now. But it's even further from being user friendly...
@jiasli What exactly is the meaning of "unofficial" here? Are these different from what is being released by Microsoft in their package repository? Or is Microsoft not releasing all versions?
I reported this here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1034526
Would it be possible to redirect people to the Debian bug tracker if they report bugs specific to the Debian packages, instead of just pointing them to this Github issue? A link to https://www.debian.org/Bugs/Reporting should be sufficient. Ubuntu bug reporting is described here: https://help.ubuntu.com/stable/ubuntu-help/report-ubuntu-bug.html.en