在 Kusto 查询中显示 JSON 属性 - 特定子网

Display JSON Properties in Kusto Query - specific Subnets

你好,我有一个小问题,我在任何地方都找不到我能理解的答案。

我即将使用 Azure Resource Graph Explorer 及其 Kusto 查询语言在 azure 中制作仪表板,我想显示订阅中有多少个子网。

但是当我尝试分离并显示其中的子网时,它只显示存在的 Vnet 数量,或者显示一行子网而不是多少。

我已经尝试使用以下代码来投影子网,但不知道要写什么来显示包含两行名称为“子网”的单行以及其中的数量。

总结:是那个;我想编写一个 Kusto 查询,我可以将其固定到显示有多少子网的仪表板。

我尝试编写的代码:

resources
| project properties.subnets

输出为: properties_subnets

null
[{"type":"Microsoft.Network/virtualNetworks/subnets","properties":{"provisioningState":"Succeeded", etc. etc. etc. 






{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "virtualNetworks_Vnet_name": {
            "defaultValue": "Vnet",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2020-05-01",
            "name": "[parameters('virtualNetworks_Vnet_name')]",
            "location": "westeurope",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "10.0.0.0/16"
                    ]
                },
                "subnets": [
                    {
                        "name": "default",
                        "properties": {
                            "addressPrefix": "10.0.0.0/24",
                            "delegations": [],
                            "privateEndpointNetworkPolicies": "Enabled",
                            "privateLinkServiceNetworkPolicies": "Enabled"
                        }
                    },
                    {
                        "name": "default2",
                        "properties": {
                            "addressPrefix": "10.0.1.0/24",
                            "serviceEndpoints": [],
                            "delegations": [],
                            "privateEndpointNetworkPolicies": "Enabled",
                            "privateLinkServiceNetworkPolicies": "Enabled"
                        }
                    }
                ],
                "virtualNetworkPeerings": [],
                "enableDdosProtection": false,
                "enableVmProtection": false
            }
        },
        {
            "type": "Microsoft.Network/virtualNetworks/subnets",
            "apiVersion": "2020-05-01",
            "name": "[concat(parameters('virtualNetworks_Vnet_name'), '/default')]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_Vnet_name'))]"
            ],
            "properties": {
                "addressPrefix": "10.0.0.0/24",
                "delegations": [],
                "privateEndpointNetworkPolicies": "Enabled",
                "privateLinkServiceNetworkPolicies": "Enabled"
            }
        },
        {
            "type": "Microsoft.Network/virtualNetworks/subnets",
            "apiVersion": "2020-05-01",
            "name": "[concat(parameters('virtualNetworks_Vnet_name'), '/default2')]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_Vnet_name'))]"
            ],
            "properties": {
                "addressPrefix": "10.0.1.0/24",
                "serviceEndpoints": [],
                "delegations": [],
                "privateEndpointNetworkPolicies": "Enabled",
                "privateLinkServiceNetworkPolicies": "Enabled"
            }
        }
    ]
}
resources 
| where type=~"Microsoft.Network/virtualNetworks" 
| project array_length(properties.subnets)