azure-cli: az cli throws error on az login and other commands

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az login

Errors:

The command failed with an unexpected error. Here is the traceback:
__init__() got an unexpected keyword argument 'user_agent'
Traceback (most recent call last):
  File "/home/vedran/.local/lib/python3.8/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/command_modules/profile/custom.py", line 152, in login
    subscriptions = profile.find_subscriptions_on_login(
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 201, in find_subscriptions_on_login
    subscriptions = subscription_finder.find_through_authorization_code_flow(
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 929, in find_through_authorization_code_flow
    result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource)
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 973, in _find_using_common_tenant
    client = self._arm_client_factory(token_credential)
  File "/home/vedran/.local/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 891, in create_arm_client_factory
    client = client_type(credentials, api_version=api_version,
TypeError: __init__() got an unexpected keyword argument 'user_agent'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps hereā€¦
  • az login

Expected Behavior

Environment Summary

Linux-5.11.0-34-generic-x86_64-with-glibc2.29, Ubuntu 20.04.3 LTS
Python 3.8.10
Installer: PIP

azure-cli 2.28.0

Extensions:
azure-devops 0.17.0

Additional Context

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@dewa55, I am glad to know it works for you.

This time the issue is not caused by pip, but apt which installs unofficial Azure CLI from Ubuntu repo, judging by the installation folder /usr/lib/python3/dist-packages/azure* (notice the dist-packages). This Azure CLI is not maintained by Microsoft (#19640).

The official Azure CLI is installed at /opt/az/lib/python3.6/site-packages/ (notice the site-packages).

Yes, sudo rm -rf /usr/lib/python3/dist-packages/azure* will do the job. An easier way is to run sudo apt remove azure-cli -y && sudo apt autoremove -y to remove this unofficial Azure CLI.