question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: AttributeError: 'DefaultAzureCredential' object has no attribute 'signed_session'

See original GitHub issue
  • Package Name: azure.mgmt.policyinsights

  • Package Version: azure-mgmt-policyinsights==0.6.0

  • Azure Packages Version: azure-common==1.1.25 azure-core==1.9.0 azure-identity==1.5.0 azure-mgmt-core==1.2.2 azure-mgmt-policyinsights==0.6.0 azure-mgmt-resource==15.0.0 azure-mgmt-storage==16.0.0 msrestazure==0.6.4

  • Operating System: MacOS

  • Python Version: Python 3.8.5

Describe the bug Getting this error while performing operation in this library: AttributeError: ‘DefaultAzureCredential’ object has no attribute ‘signed_session’

To Reproduce Try calling this method: https://docs.microsoft.com/en-us/python/api/azure-mgmt-policyinsights/azure.mgmt.policyinsights.operations.operations?view=azure-python

import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import SubscriptionClient
from azure.mgmt.policyinsights import PolicyInsightsClient

credential = DefaultAzureCredential()
subscription_client = SubscriptionClient(credential)

# This works
subscription = next(subscription_client.subscriptions.list())
print(subscription.subscription_id)


policy_client = PolicyInsightsClient(credentials=credential)

# This fails
policy_client.operations.list()

Expected behavior

List method mentioned above should’ve listed operation.

Additional context Found this error at: https://docs.microsoft.com/en-us/azure/developer/python/azure-sdk-authenticate?view=azure-python&tabs=cmd#defaultazurecredential-object-has-no-attribute-signed-session

Currently using DefaultAzureCredential with version 15.0.0 or higher of azure-mgmt-resource : azure-mgmt-resource==15.0.0.

Still facing this issue

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
chlowellcommented, Nov 16, 2020

PolicyInsightsClient expects a credential type from msrestazure but azure-identity credentials have a different API. I think you could use AzureIdentityCredentialAdapter to wrap DefaultAzureCredential for PolicyInsightsClient:

credential = DefaultAzureCredential()
subscription_client = SubscriptionClient(credential)

wrapped_credential = AzureIdentityCredentialAdapter(credential)
policy_client = PolicyInsightsClient(credentials=wrapped_credential)

A future version of azure-mgmt-policyinsights may not require the adapter, but I don’t know the roadmap for that library. @changlong-liu is a track 2 version planned?

(Related: #14499)

1reaction
msyyccommented, Nov 18, 2020

I have a try and the above solution works well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception: AttributeError: 'DefaultAzureCredential' object has ...
The error I am getting is: Exception: AttributeError: 'DefaultAzureCredential' object has no attribute 'signed_session' I've done tons of ...
Read more >
AttributeError: 'DefaultAzureCredential' object has no ... - Ray.io
Hi! I am having difficulty setting up Ray autoscaler with Azure. The cluster is created and the head node works fine but the...
Read more >
AttributeError: 'AzureCliCredential' object has no attribute ...
hello, I'm new to azure and I am running a function app locally, I faced the problem of extensionBundle and after deleting it...
Read more >
Attributeerror When Packaging Python Library - ADocLib
The code is available on GitHub but not published to PyPI. Error: AttributeError: 'DefaultAzureCredential' object has no attribute 'signedsession' #15330.
Read more >
Azure SDK for Python - Gitter
Error : self._token = self._credential.get_token(*self._scopes) AttributeError: 'AzureSasCredential' object has no attribute 'get_token'
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found