如何通过Azure Graph Explorer获取指定资源类型的专用终结点信息?
使用Azure Graph Explorer获取专用终结点信息
可以通过Azure Graph Explorer实现该需求,只需编写对应的Kusto查询语句,即可提取并整理出你需要的字段数据。
示例查询代码
针对Event Hubs、Key Vault和MySQL Flexible Server这三类资源,查询语句如下:
resources | where type in ( "Microsoft.EventHub/namespaces", "Microsoft.KeyVault/vaults", "Microsoft.DBforMySQL/flexibleServers" ) | project resourceId = id, resourceName = name, resourceType = type | join kind=inner ( resources | where type == "Microsoft.Network/privateEndpoints" | project privateEndpointName = name, privateEndpointIp = tostring(properties.ipAddresses[0]), subnetId = properties.subnet.id, privateLinkConnections = properties.privateLinkServiceConnections | mv-expand privateLinkConnections | project privateEndpointName, privateEndpointIp, subnetId, connectedResourceId = tostring(privateLinkConnections.properties.privateLinkServiceId) ) on $left.resourceId == $right.connectedResourceId | extend subnetName = split(subnetId, '/')[-1] | project 资源名称 = resourceName, 连接至该资源的专用终结点 = privateEndpointName, 专用终结点的IP地址 = privateEndpointIp, 专用终结点所在的子网 = subnetName | sort by resourceType asc
查询逻辑说明
- 首先筛选出目标类型的资源(Event Hubs、Key Vault、MySQL),提取资源ID和名称;
- 关联所有专用终结点资源,展开其私有链接连接属性,匹配到对应的目标资源ID;
- 从子网ID中提取子网名称(通过分割ID字符串取最后一段);
- 最终整理成你需要的四个字段,并按资源类型排序。
示例结果
执行查询后会返回类似以下格式的表格:
| 资源名称 | 连接至该资源的专用终结点 | 专用终结点的IP地址 | 专用终结点所在的子网 |
|---|---|---|---|
| my-eventhub-ns | pe-eventhub | 10.0.1.5 | subnet-pe |
| my-kv-vault | pe-keyvault | 10.0.1.6 | subnet-pe |
| my-mysql-server | pe-mysql | 10.0.1.7 | subnet-db |
自定义调整
如果需要查询其他资源类型,只需修改第一个where type in (...)中的类型值即可,比如添加"Microsoft.Storage/storageAccounts"来查询存储账户的专用终结点。
内容的提问来源于stack exchange,提问作者Steve
相关产品推荐
相关产品推荐

