简体   繁体   English

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

[英]Getting error in Linux printing Security group in azure

I have this code and I have written it in windows.我有这段代码,我已经在 Windows 中编写了它。 and it works fine in windows but when I run it on Linux and I have to run it on Linux as of my project needs and it does not works there and gives me the following error它在 Windows 中运行良好,但是当我在 Linux 上运行它时,我必须根据我的项目需要在 Linux 上运行它,它在那里不起作用并给我以下错误

AttributeError: 'ServicePrincipalCredentials' object has no attribute 'get_token' 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)

Assuming you are using latest version of azure-mgmt-security, it works with azure-identity package.假设您使用的是最新版本的 azure-mgmt-security,它适用于 azure-identity 包。

eginstead of from azure.common.credentials import ServicePrincipalCredentials, you can use from azure.identity import ClientSecretCredential.例如,您可以使用 from azure.identity import ClientSecretCredentials 而不是 from azure.common.credentials import ServicePrincipalCredentials。

(I work in MS in the SDK team) (我在 SDK 团队的 MS 工作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM