gpt4 book ai didi

python - Linux 在 azure 中打印安全组时出错

转载 作者:行者123 更新时间:2023-12-03 05:21:08 25 4
gpt4 key购买 nike

我有这段代码,并且是在 Windows 中编写的。它在 Windows 中运行良好,但是当我在 Linux 上运行它时,我必须根据我的项目需要在 Linux 上运行它,但它在那里不起作用并给出以下错误

AttributeError: 'ServicePrincipalCredentials' object has no attribute'get_token'

from azure.mgmt.security import SecurityCenter
from azure.common.credentials import ServicePrincipalCredentials
import Credentials
from pprint import pprint

client = SecurityCenter(Credentials.credential,Credentials.subscription_id,asc_location="")

for score in client.secure_scores.list():
print(score)

最佳答案

假设您使用的是最新版本的 azure-mgmt-security,它可以与 azure-identity 包配合使用。

例如,您可以使用 from azure.identity import ClientSecretCredentials,而不是 from azure.common.credentials import ServicePrincipalCredentials。

(我在 MS SDK 团队工作)

关于python - Linux 在 azure 中打印安全组时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72321773/

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