azure - 在 Azure Resource Graph 中查询资源子类型
问题描述
我正在尝试使用 Azure Policy 的资源图查询事件中心防火墙 IP 规则。我目前使用以下防火墙 IP 规则配置了一个事件中心。
{
"type": "Microsoft.EventHub/namespaces/ipfilterrules",
"apiVersion": "2018-01-01-preview",
"name": "[concat(parameters('namespaces_myeventhub_name'), '/e51110a0-c074-43b3-85b7-b43e2eab4d9b')]",
"location": "West US 2",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', parameters('namespaces_myeventhub_name'))]"
],
"properties": {
"ipMask": "47.xxx.xxx.xxx",
"action": "Accept",
"filterName": "e51110a0-c074-43b3-85b7-b43e2eax4d9b"
}
}
查询
"where type =~ 'Microsoft.EventHub/namespaces'"
将在没有任何防火墙 IP 规则信息的情况下显示我的事件中心。此外还有一个查询
where type =~ 'Microsoft.EventHub/namespaces/ipfilterrules'
什么都不返回。我希望能够使用资源图查询这些信息,并最终针对这些属性编写 Azure 策略。我使用以下信息搜索了可能的别名
"where type =~ 'Microsoft.EventHub/namespaces' | limit 1 | project aliases"
但它返回的列表不包含事件中心的防火墙 IP 规则信息。这似乎是资源图中应该提供的基本信息......我错过了什么?
解决方案
经过测试,遗憾的是,只能通过 Azure Resource Graph API 查询事件中心命名空间的级别,不能直接通过 Azure Resource Graph 查询 ipfilterrules,请参考以下解决方案作为解决方法:
1:查询所有订阅下的事件中心命名空间 例如: https: //management.azure.com/subscriptions/ /providers/Microsoft.EventHub/namespaces?api-version=2018-01-01-preview
2:查询事件中心命名空间下的所有ipfilterrules,并在你的程序中一一过滤ipfilterrules。例如 https://management.azure.com/subscriptions/ /resourceGroups/ericm/providers/Microsoft.EventHub/namespaces//ipfilterrules?api-version=2018-01-01-preview
希望对您的关心有所帮助。
推荐阅读
- reactjs - 如何将ant design类组件转换为功能组件
- java - 使用 Jsoup 将数据从网页解析到 Android 应用
- python - 可以导入pytorch但不能导入torch
- angular - Angular 2方式绑定组件
- python - 使用 Selenium 和 Python 从 svg 标签中的 g 标签获取文本
- javascript - 在evennode.com的真实主机上使用mongodb的问题
- excel - 如何改进将 14 列月薪表转换为 4 列数据集的 VBA 代码
- javascript - 如何在 DeviceMotionEvent javascript 中设置间隔
- sqlite - 如何将片假名添加到 SQLite3?
- unity3d - 如何更改 Vuforia AnchorInputListenerBehaviour?