【发布时间】:2021-02-28 13:11:11
【问题描述】:
您好,我有一个小问题,我在任何地方都找不到我能理解的答案。
我即将使用 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"
}
}
]
}
【问题讨论】:
-
您想要在 json 输出中显示 included 的输出也是如此。还是您需要查找其他查询?
-
子网是虚拟网络的一个属性(子项),我想编写一个查询,只选择子网并显示有多少子网。如果这有意义
-
你想从收到的json中挑出哪个字段?
-
我已经更新了我的问题,将我的虚拟网络包含在问题的底部和一个 JSON - 然后我想要查询子网的数量