Skip to content

AzureCliCredential interrupts credential chain if Azure CLI is not logged in #11819

@mpderbec

Description

@mpderbec
  • Package Name: azure-identity
  • Package Version: 1.4.0b3
  • Operating System: Windows
  • Python Version: 3.7

Describe the bug
On Windows (haven't tried other OSes, but would expect the same), if the Azure CLI client is logged out, then the AzureCliCredential class will raise ClientAuthenticationError, which causes the credential chain to stop. A common need is to include InteractiveBrowserCredential as the final link in a chained credential, and this bug prevents it from being used.

To Reproduce
Steps to reproduce the behavior:

  1. Use the following credential, which behind the scenes creates a chain:
        credential = identity.DefaultAzureCredential(
            exclude_shared_token_cache_credential=False,
            exclude_visual_studio_code_credential=False,
            exclude_cli_credential=False,
            exclude_interactive_browser_credential=False
        )
  1. Make sure Visual Studio Code is logged out of Azure and that the Azure CLI is also logged out.
  2. Use the credential for some purpose that would cause it to retrieve a token.

Expected behavior
I believe if the AzureCliCredential class were to raise CredentialUnavailableError instead, then the chain would continue.

Additional context
Found in the course of attempting to work around Azure/azure-sdk-for-net#8934.

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions