You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

查询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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 18:12:38