gpt4 book ai didi

azure - 错误 'ClientSecretCredential' 对象没有属性 'signed_session'

转载 作者:行者123 更新时间:2023-12-02 06:16:43 28 4
gpt4 key购买 nike

我试图收集特定租户中存在的拒绝分配列表,因此我在此处传递了所需的参数:

tenant_id = arguments['tenant_id']
client_id = arguments['client_id']
client_secret = arguments['client_secret']

我在这里创建了ClientSecretCredentials:

csc = ClientSecretCredential(tenant_id=tenant_id,
client_id=client_id,
client_secret=client_secret)

从其他一些代码中,我收到了订阅 ID 列表:

for subscription_id in subscription_id_list:
resource_client = authenticate.resource_client(subscription_id)
resources_groups = get_all_resource_groups_detail(resource_client)

我可以使用以下代码在该订阅 ID 中获取 resourceGroups:

    amc = AuthorizationManagementClient(csc, subscription_id)
for resource_group in resources_groups:
denylocks = amc.deny_assignments.list_for_resource_group(resource_group)
try:

在这里,它会产生一个错误(denylocks);我得到:

<azure.mgmt.authorization.v2018_07_01_preview.models._paged_models.DenyAssignmentPaged object>

当我循环该对象的列表时,它给出错误

:ERROR 'ClientSecretCredential' object has no attribute'signed_session'

for locks in denylocks:
print(locks)
except Exception as exc:
logger.error(exc)

最佳答案

'ClientSecretCredential' object has no attribute 'signed_session'

要解决上述错误,根据documentation :

  • 当给定 azure-identity< 时,需要 azure-common 凭据的客户端将引发类似 'ClientSecretCredential' object has no attribute 'signed_session' 的错误 凭证。

因此,请尝试根据documentation执行以下代码片段:

  • azure-common 使用 ServicePrincipalCredentials 对服务主体进行身份验证:
from azure.common.credentials import ServicePrincipalCredentials

credential = ServicePrincipalCredentials(client_id, client_secret, tenant=tenant_id)

或者,您可以将 azure.mgmt.authorization 升级到最新版本,并继续使用 azure-identityClientSecretCredential

关于azure - 错误 'ClientSecretCredential' 对象没有属性 'signed_session',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73041255/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com