I was trying to collect the List of Deny Assignments present in a particular tenant, so I passed the required arguments here:
tenant_id = arguments['tenant_id']
client_id = arguments['client_id']
client_secret = arguments['client_secret']
I created ClientSecretCredentials
here:
csc = ClientSecretCredential(tenant_id=tenant_id,
client_id=client_id,
client_secret=client_secret)
From some other code, I have received a list of subscription IDs:
for subscription_id in subscription_id_list:
resource_client = authenticate.resource_client(subscription_id)
resources_groups = get_all_resource_groups_detail(resource_client)
I am able to get resourceGroups
in that subscription id using this code:
amc = AuthorizationManagementClient(csc, subscription_id)
for resource_group in resources_groups:
denylocks = amc.deny_assignments.list_for_resource_group(resource_group)
try:
Here, it creates an error (denylocks
); I am getting:
<azure.mgmt.authorization.v2018_07_01_preview.models._paged_models.DenyAssignmentPaged object>
When I loop over the list of that object, it gives the error
:ERROR ‘ClientSecretCredential’ object has no attribute
‘signed_session’
for locks in denylocks:
print(locks)
except Exception as exc:
logger.error(exc)
2
Answers
To resolve above error, according to documentation:
azure-common
credential will raise an error like'ClientSecretCredential' object has no attribute 'signed_session'
when given anazure-identity
credential.So, try following code snippet according to documentation:
azure-common
usesServicePrincipalCredentials
to authenticate a service principal:Alternatively, you can upgrade
azure.mgmt.authorization
to the latest version and continue usingClientSecretCredential
ofazure-identity
.It’s because of the
azure.mgmt.resource
package, its latest version have some issue.Try the following command:
pip install azure.mgmt.resource==21.2.1