在azure中打印Linux安全组时出现错误



我有这个代码,我已经在windows中编写了它。它在windows上工作得很好,但当我在Linux上运行它时,我必须在Linux上运行它,因为我的项目需要,它在那里不起作用,给了我以下错误

AttributeError: 'ServicePrincipalCredentials'对象没有属性"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- management -security,它可以与azure-identity包一起使用。

。你可以使用from azure来代替从azure.common.credentials导入ServicePrincipalCredentials。identity import ClientSecretCredential.

(我在MS的SDK团队工作)

最新更新