查询Azure所有VNET中自定义DNS服务器的Kusto语句咨询
Azure VNET自定义DNS服务器查询修正
你的原查询存在几个问题,导致无法正确获取目标数据:
- 错误使用
[0] == "*":自定义DNS服务器是数组类型,直接取索引0仅会匹配第一个元素为*的情况,且Kusto中不能用*作为通配符这样匹配;默认DNS配置下dnsServers数组为空,自定义DNS则是具体IP列表。 summarize的分组字段错误:'dnsServers'是字符串字面量,不是实际的字段引用,无法按DNS服务器分组统计。
正确查询1:列出所有配置自定义DNS的VNET及对应DNS服务器
resources | where type == "microsoft.network/virtualnetworks" | where array_length(properties.dhcpOptions.dnsServers) > 0 // 过滤掉使用默认DNS的VNET | project VNETName = name, ResourceGroup = resourceGroup, DNSServers = properties.dhcpOptions.dnsServers
正确查询2:统计每个自定义DNS服务器被多少VNET使用
resources | where type == "microsoft.network/virtualnetworks" | where array_length(properties.dhcpOptions.dnsServers) > 0 | mv-expand DNSServer = properties.dhcpOptions.dnsServers // 展开DNS服务器数组 | summarize VNETCount = count() by DNSServer
内容的提问来源于stack exchange,提问作者Jon Granger
相关产品推荐
相关产品推荐

