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

Getting error in Linux printing Security group in azure

我有这段代码,我已经把它写在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 软件包。

e.g.instead of from azure.common.credentials import ServicePrincipalCredentials,可以使用from azure.identity import ClientSecretCredential.

(我在 SDK 团队从事 MS 工作)