通过python SDK获取Azure安全中心警报 [英] Get Azure Security Center alerts via python SDK
问题描述
我想使用python SDK列出azure安全中心警报.
I want to list azure security center alerts using the python SDK.
我找到了这个包裹: https://pypi.org/project/azure-mgmt-security/
它必须包含在Microsoft文档中:
It must be included in the microsoft documentation:
https://docs.microsoft.com/zh-CN/python/azure/?view = azure-python https://github.com/Azure/azure-sdk-for-python
但我找不到任何参考或示例.
but I can not find any reference or example.
有人知道我在哪里可以找到此信息吗?
Does anyone know where I can find this information?
最诚挚的问候.
推荐答案
我可以提供一个大概的参考.
I can just give a rough reference.
在安装软件包 azure-mgmt-security 后,您应该使用<包中的code> List 方法,源代码为
After install the package azure-mgmt-security, you should use List
method in the package, source code is here.
这是文档说明如何进行身份验证.这是 doc 如何获取tenantId/client_id/密钥.
Here is the the doc on how to authentication. Here is doc on how to get 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()
此外,您可以使用列表警报api 在python中带有http请求.
Also, you can use List Alerts api with a http request in python.
这篇关于通过python SDK获取Azure安全中心警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!