python - 通过 python SDK 获取 Azure 安全中心警报
问题描述
我想使用 python SDK 列出 azure 安全中心警报。
我找到了这个包: https ://pypi.org/project/azure-mgmt-security/
它必须包含在 microsoft 文档中:
https://docs.microsoft.com/en-gb/python/azure/?view=azure-python https://github.com/Azure/azure-sdk-for-python
但我找不到任何参考或示例。
有谁知道我在哪里可以找到这些信息?
此致。
解决方案
我只能提供一个粗略的参考。
安装包azure-mgmt-security后,你应该使用List
包中的方法,源代码在这里。
这是有关如何进行身份验证的文档。这是有关如何获取tenantId / client_id / key的文档。
这是我的代码:
from azure.mgmt.security import SecurityCenter
from azure.common.credentials import ServicePrincipalCredentials
subscription_id = "xxxx"
# Tenant ID for your Azure subscription
TENANT_ID = '<Your tenant ID>'
# Your service principal App ID
CLIENT = '<Your service principal ID>'
# Your service principal password
KEY = '<Your service principal password>'
credentials = ServicePrincipalCredentials(
client_id = CLIENT,
secret = KEY,
tenant = TENANT_ID
)
client = SecurityCenter(credentials=credentials,subscription_id=subscription_id,asc_location="centralus")
client.alerts.list()
此外,您可以在 python 中将List Alerts api与 http 请求一起使用。
推荐阅读
- mysql - 如何预处理使用 sqlx 获取的行?
- c# - 如何使用 sql server 身份验证模式从 .NET Webapi 执行 SSIS 包?
- javascript - 为什么 content.js 只执行最后一个命令
- javascript - 选择下拉选项后Laravel重复视图
- android - 如何仅通过 wifi 强制互联网连接?
- javascript - 设置多个`' 使用变量值的字段
- php - 我在我的代码中使用 Stripe API,但出现错误:您不能多次使用 Stripe 令牌:tok_1EIw1gKIAV9zC39qQnFXKzi6
- spring-boot - 如果 Ignite 连接失败,继续 Springboot 启动
- scala - sparksession文本和文本文件方法之间的区别?
- python - 为什么集合的增强分配表现不同?