Azure / Azure/azure-cli

az command fails with "cannot import name 'ChallengeAuthenticationPolicy' from 'azure.core.pipeline.policies'"

Open
#18,025 2 comments 0 reactions 1 assignee Claimed by @jiasli View on GitHub
Account act-identity-squad feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

One of the recent updates of one of the Azure SDK components broke the Azure CLI again.

I have not yet been able to localize the problem, but I am reporting it here through `az feedback` anyway in the hope to get some pointers to what could be the problem.

This issue shows with the packaged version of the Python Azure SDK and Azure CLI packages on openSUSE Tumbleweed. There might be a version mismatch of any of the component packages but I have not figured out yet which package is the culprit.

## Describe the bug

**Command Name**
`az login`

**Errors:**
```
The command failed with an unexpected error. Here is the traceback:
cannot import name 'ChallengeAuthenticationPolicy' from 'azure.core.pipeline.policies' (/usr/lib/python3.8/site-packages/azure/core/pipeline/policies/__init__.py)
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
raise ex
File "/usr/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 "/usr/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
result = cmd_copy(params)
File "/usr/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
return self.handler(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/usr/lib/python3.8/site-packages/azure/cli/command_modules/profile/custom.py", line 152, in login
subscriptions = profile.find_subscriptions_on_login(
File "/usr/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 "/usr/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 917, in find_through_authorization_code_flow
result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource)
File "/usr/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 961, in _find_using_common_tenant
client = self._arm_client_factory(token_credential)
File "/usr/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 871, in create_arm_client_factory
client_type = self._get_subscription_client_class()
File "/usr/lib/python3.8/site-packages/azure/cli/core/_profile.py", line 1050, in _get_subscription_client_class
from azure.cli.core.vendored_sdks.subscriptions import SubscriptionClient
File "/usr/lib/python3.8/site-packages/azure/cli/core/vendored_sdks/subscriptions/__init__.py", line 9, in
from ._subscription_client import SubscriptionClient
File "/usr/lib/python3.8/site-packages/azure/cli/core/vendored_sdks/subscriptions/_subscription_client.py", line 12, in
from azure.mgmt.core import ARMPipelineClient
File "/usr/lib/python3.8/site-packages/azure/mgmt/core/__init__.py", line 29, in
from ._pipeline_client import ARMPipelineClient
File "/usr/lib/python3.8/site-packages/azure/mgmt/core/_pipeline_client.py", line 32, in
from .policies import ARMAutoResourceProviderRegistrationPolicy, ARMHttpLoggingPolicy
File "/usr/lib/python3.8/site-packages/azure/mgmt/core/policies/__init__.py", line 28, in
from ._authentication import ARMChallengeAuthenticationPolicy
File "/usr/lib/python3.8/site-packages/azure/mgmt/core/policies/_authentication.py", line 32, in
from azure.core.pipeline.policies import ChallengeAuthenticationPolicy
ImportError: cannot import name 'ChallengeAuthenticationPolicy' from 'azure.core.pipeline.policies' (/usr/lib/python3.8/site-packages/azure/core/pipeline/policies/__init__.py)

```

## 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.12.0-2-default-x86_64-with-glibc2.2.5
Python 3.8.9
Installer: PIP

azure-cli 2.23.0

```
## Additional Context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.