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:
- Created 3 years ago
- Comments:7 (4 by maintainers)

Top Related StackOverflow Question
PolicyInsightsClientexpects a credential type from msrestazure but azure-identity credentials have a different API. I think you could use AzureIdentityCredentialAdapter to wrapDefaultAzureCredentialforPolicyInsightsClient: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)
I have a try and the above solution works well.