Skip to content

Commit 93315a4

Browse files
committed
fixes commands
1 parent 0a3aaf8 commit 93315a4

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

articles/governance/includes/resource-graph/query/virtual-machine-basic-sku-public-ip.md

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,40 @@ This query returns a list of Virtual Machines IDs with Basic SKU Public IP addre
1212

1313
```kusto
1414
Resources
15-
| where type =~ 'microsoft.compute/virtualmachines'
16-
| project vmId = tolower(id), vmNics = properties.networkProfile.networkInterfaces
17-
| join (
18-
Resources |
19-
where type =~ 'microsoft.network/networkinterfaces' |
20-
project nicVMId = tolower(tostring(properties.virtualMachine.id)), allVMNicID = tolower(id), nicIPConfigs = properties.ipConfigurations)
21-
on $left.vmId == $right.nicVMId
22-
| join (
23-
Resources
24-
| where type =~ 'microsoft.network/publicipaddresses' and isnotnull(properties.ipConfiguration.id)
25-
| where sku.name == 'Basic' // exclude to find all VMs with Public IPs
26-
| project pipId = id, pipSku = sku.name, pipAssociatedNicId = tolower(tostring(split(properties.ipConfiguration.id, '/ipConfigurations/')[0])))
27-
on $left.allVMNicID == $right.pipAssociatedNicId
28-
| project vmId, pipId, pipSku
15+
| where type =~ 'microsoft.compute/virtualmachines'
16+
| project vmId = tolower(id), vmNics = properties.networkProfile.networkInterfaces
17+
| join (
18+
Resources |
19+
where type =~ 'microsoft.network/networkinterfaces' |
20+
project nicVMId = tolower(tostring(properties.virtualMachine.id)), allVMNicID = tolower(id), nicIPConfigs = properties.ipConfigurations)
21+
on $left.vmId == $right.nicVMId
22+
| join (
23+
Resources
24+
| where type =~ 'microsoft.network/publicipaddresses' and isnotnull(properties.ipConfiguration.id)
25+
| where sku.name == 'Basic' // exclude to find all VMs with Public IPs
26+
| project pipId = id, pipSku = sku.name, pipAssociatedNicId = tolower(tostring(split(properties.ipConfiguration.id, '/ipConfigurations/')[0])))
27+
on $left.allVMNicID == $right.pipAssociatedNicId
28+
| project vmId, pipId, pipSku
2929
```
3030

3131
# [Azure CLI](#tab/azure-cli)
3232

3333
```azurecli-interactive
34-
az graph query -q "Resources | where type =~ 'microsoft.compute/virtualmachines' | project vmId = tolower(id), vmNics = properties.networkProfile.networkInterfaces | join ( Resources | where type =~ 'microsoft.network/networkinterfaces' | project nicVMId = tolower(tostring(properties.virtualMachine.id)), allVMNicID = tolower(id), nicIPConfigs = properties.ipConfigurations) on $left.vmId == $right.nicVMId | join ( Resources | where type =~ 'microsoft.network/publicipaddresses' and isnotnull(properties.ipConfiguration.id) | where sku.name == 'Basic' | project pipId = id, pipSku = sku.name, pipAssociatedNicId = tolower(tostring(split(properties.ipConfiguration.id, '/ipConfigurations/')[0]))) on $left.allVMNicID == $right.pipAssociatedNicId | project vmId, pipId, pipSku"
34+
az graph query -q "Resources | where type =~ 'microsoft.compute/virtualmachines' | project vmId = tolower(id), vmNics = properties.networkProfile.networkInterfaces | join (Resources | where type =~ 'microsoft.network/networkinterfaces' | project nicVMId = tolower(tostring(properties.virtualMachine.id)), allVMNicID = tolower(id), nicIPConfigs = properties.ipConfigurations) on \$left.vmId == \$right.nicVMId | join ( Resources | where type =~ 'microsoft.network/publicipaddresses' and isnotnull(properties.ipConfiguration.id) | where sku.name == 'Basic' | project pipId = id, pipSku = sku.name, pipAssociatedNicId = tolower(tostring(split(properties.ipConfiguration.id, '/ipConfigurations/')[0]))) on \$left.allVMNicID == \$right.pipAssociatedNicId | project vmId, pipId, pipSku"
3535
```
3636

3737
# [Azure PowerShell](#tab/azure-powershell)
3838

3939
```azurepowershell-interactive
40-
Search-AzGraph -Query @"
41-
Resources
42-
| where type =~ 'microsoft.compute/virtualmachines'
43-
| project vmId = tolower(id), vmNics = properties.networkProfile.networkInterfaces
44-
| join (
45-
Resources |
46-
where type =~ 'microsoft.network/networkinterfaces' |
47-
project nicVMId = tolower(tostring(properties.virtualMachine.id)), allVMNicID = tolower(id), nicIPConfigs = properties.ipConfigurations)
48-
on `$left.vmId == `$right.nicVMId
49-
| join (
50-
Resources
51-
| where type =~ 'microsoft.network/publicipaddresses' and isnotnull(properties.ipConfiguration.id)
52-
| where sku.name == 'Basic' // exclude to find all VMs with Public IPs
53-
| project pipId = id, pipSku = sku.name, pipAssociatedNicId = tolower(tostring(split(properties.ipConfiguration.id, '/ipConfigurations/')[0])))
54-
on `$left.allVMNicID == `$right.pipAssociatedNicId
55-
| project vmId, pipId, pipSku
56-
"@
40+
Search-AzGraph -Query "Resources | where type =~ 'microsoft.compute/virtualmachines' | project vmId = tolower(id), vmNics = properties.networkProfile.networkInterfaces | join (Resources | where type =~ 'microsoft.network/networkinterfaces' | project nicVMId = tolower(tostring(properties.virtualMachine.id)), allVMNicID = tolower(id), nicIPConfigs = properties.ipConfigurations) on `$left.vmId == `$right.nicVMId | join ( Resources | where type =~ 'microsoft.network/publicipaddresses' and isnotnull(properties.ipConfiguration.id) | where sku.name == 'Basic' | project pipId = id, pipSku = sku.name, pipAssociatedNicId = tolower(tostring(split(properties.ipConfiguration.id, '/ipConfigurations/')[0]))) on `$left.allVMNicID == `$right.pipAssociatedNicId | project vmId, pipId, pipSku"
5741
```
5842

5943
# [Portal](#tab/azure-portal)
6044

6145
:::image type="icon" source="../../../resource-graph/media/resource-graph-small.png"::: Try this query in Azure Resource Graph Explorer:
6246

63-
- Azure portal: <a href="https://portal.azure.com/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/Resources%20%7C%20where%20type%20%3D~%20'microsoft.compute%2Fvirtualmachines'%20%7C%20project%20vmId%20%3D%20tolower(id)%2C%20vmNics%20%3D%20properties.networkProfile.networkInterfaces%20%7C%20join%20(%20Resources%20%7C%20where%20type%20%3D~%20'microsoft.network%2Fnetworkinterfaces'%20%7C%20project%20nicVMId%20%3D%20tolower(tostring(properties.virtualMachine.id))%2C%20allVMNicID%20%3D%20tolower(id)%2C%20nicIPConfigs%20%3D%20properties.ipConfigurations)%20on%20%24left.vmId%20%3D%3D%20%24right.nicVMId%20%7C%20join%20(%20Resources%20%7C%20where%20type%20%3D~%20'microsoft.network%2Fpublicipaddresses'%20and%20isnotnull(properties.ipConfiguration.id)%20%7C%20where%20sku.name%20%3D%3D%20'Basic'%20%%7C%20project%20pipId%20%3D%20id%2C%20pipSku%20%3D%20sku.name%2C%20pipAssociatedNicId%20%3D%20tolower(tostring(split(properties.ipConfiguration.id%2C%20'%2FipConfigurations%2F')%5B0%5D)))%20on%20%24left.allVMNicID%20%3D%3D%20%24right.pipAssociatedNicId%20%7C%20project%20vmId%2C%20pipId%2C%20pipSku" target="_blank">portal.azure.com</a>
64-
- Azure Government portal: <a href="https://portal.azure.us/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/Resources%20%7C%20where%20type%20%3D~%20'microsoft.compute%2Fvirtualmachines'%20%7C%20project%20vmId%20%3D%20tolower(id)%2C%20vmNics%20%3D%20properties.networkProfile.networkInterfaces%20%7C%20join%20(%20Resources%20%7C%20where%20type%20%3D~%20'microsoft.network%2Fnetworkinterfaces'%20%7C%20project%20nicVMId%20%3D%20tolower(tostring(properties.virtualMachine.id))%2C%20allVMNicID%20%3D%20tolower(id)%2C%20nicIPConfigs%20%3D%20properties.ipConfigurations)%20on%20%24left.vmId%20%3D%3D%20%24right.nicVMId%20%7C%20join%20(%20Resources%20%7C%20where%20type%20%3D~%20'microsoft.network%2Fpublicipaddresses'%20and%20isnotnull(properties.ipConfiguration.id)%20%7C%20where%20sku.name%20%3D%3D%20'Basic'%20%%7C%20project%20pipId%20%3D%20id%2C%20pipSku%20%3D%20sku.name%2C%20pipAssociatedNicId%20%3D%20tolower(tostring(split(properties.ipConfiguration.id%2C%20'%2FipConfigurations%2F')%5B0%5D)))%20on%20%24left.allVMNicID%20%3D%3D%20%24right.pipAssociatedNicId%20%7C%20project%20vmId%2C%20pipId%2C%20pipSku" target="_blank">portal.azure.us</a>
65-
- Microsoft Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/Resources%20%7C%20where%20type%20%3D~%20'microsoft.compute%2Fvirtualmachines'%20%7C%20project%20vmId%20%3D%20tolower(id)%2C%20vmNics%20%3D%20properties.networkProfile.networkInterfaces%20%7C%20join%20(%20Resources%20%7C%20where%20type%20%3D~%20'microsoft.network%2Fnetworkinterfaces'%20%7C%20project%20nicVMId%20%3D%20tolower(tostring(properties.virtualMachine.id))%2C%20allVMNicID%20%3D%20tolower(id)%2C%20nicIPConfigs%20%3D%20properties.ipConfigurations)%20on%20%24left.vmId%20%3D%3D%20%24right.nicVMId%20%7C%20join%20(%20Resources%20%7C%20where%20type%20%3D~%20'microsoft.network%2Fpublicipaddresses'%20and%20isnotnull(properties.ipConfiguration.id)%20%7C%20where%20sku.name%20%3D%3D%20'Basic'%20%%7C%20project%20pipId%20%3D%20id%2C%20pipSku%20%3D%20sku.name%2C%20pipAssociatedNicId%20%3D%20tolower(tostring(split(properties.ipConfiguration.id%2C%20'%2FipConfigurations%2F')%5B0%5D)))%20on%20%24left.allVMNicID%20%3D%3D%20%24right.pipAssociatedNicId%20%7C%20project%20vmId%2C%20pipId%2C%20pipSku" target="_blank">portal.azure.cn</a>
47+
- Azure portal: <a href="https://portal.azure.com/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/Resources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fvirtualmachines%27%0A%7C%20project%20vmId%20%3D%20tolower%28id%29%2C%20vmNics%20%3D%20properties.networkProfile.networkInterfaces%0A%7C%20join%20%28%0A%20%20Resources%20%7C%0A%20%20where%20type%20%3D~%20%27microsoft.network%2Fnetworkinterfaces%27%20%7C%0A%20%20project%20nicVMId%20%3D%20tolower%28tostring%28properties.virtualMachine.id%29%29%2C%20allVMNicID%20%3D%20tolower%28id%29%2C%20nicIPConfigs%20%3D%20properties.ipConfigurations%29%0A%20%20on%20%24left.vmId%20%3D%3D%20%24right.nicVMId%0A%7C%20join%20%28%0A%20%20Resources%0A%20%20%7C%20where%20type%20%3D~%20%27microsoft.network%2Fpublicipaddresses%27%20and%20isnotnull%28properties.ipConfiguration.id%29%0A%20%20%7C%20where%20sku.name%20%3D%3D%20%27Basic%27%0A%20%20%7C%20project%20pipId%20%3D%20id%2C%20pipSku%20%3D%20sku.name%2C%20pipAssociatedNicId%20%3D%20tolower%28tostring%28split%28properties.ipConfiguration.id%2C%20%27%2FipConfigurations%2F%27%29%5B0%5D%29%29%29%0A%20%20on%20%24left.allVMNicID%20%3D%3D%20%24right.pipAssociatedNicId%0A%7C%20project%20vmId%2C%20pipId%2C%20pipSku" target="_blank">portal.azure.com</a>
48+
- Azure Government portal: <a href="https://portal.azure.us/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/Resources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fvirtualmachines%27%0A%7C%20project%20vmId%20%3D%20tolower%28id%29%2C%20vmNics%20%3D%20properties.networkProfile.networkInterfaces%0A%7C%20join%20%28%0A%20%20Resources%20%7C%0A%20%20where%20type%20%3D~%20%27microsoft.network%2Fnetworkinterfaces%27%20%7C%0A%20%20project%20nicVMId%20%3D%20tolower%28tostring%28properties.virtualMachine.id%29%29%2C%20allVMNicID%20%3D%20tolower%28id%29%2C%20nicIPConfigs%20%3D%20properties.ipConfigurations%29%0A%20%20on%20%24left.vmId%20%3D%3D%20%24right.nicVMId%0A%7C%20join%20%28%0A%20%20Resources%0A%20%20%7C%20where%20type%20%3D~%20%27microsoft.network%2Fpublicipaddresses%27%20and%20isnotnull%28properties.ipConfiguration.id%29%0A%20%20%7C%20where%20sku.name%20%3D%3D%20%27Basic%27%0A%20%20%7C%20project%20pipId%20%3D%20id%2C%20pipSku%20%3D%20sku.name%2C%20pipAssociatedNicId%20%3D%20tolower%28tostring%28split%28properties.ipConfiguration.id%2C%20%27%2FipConfigurations%2F%27%29%5B0%5D%29%29%29%0A%20%20on%20%24left.allVMNicID%20%3D%3D%20%24right.pipAssociatedNicId%0A%7C%20project%20vmId%2C%20pipId%2C%20pipSkuu" target="_blank">portal.azure.us</a>
49+
- Microsoft Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/?feature.customportal=false#blade/HubsExtension/ArgQueryBlade/query/Resources%0A%7C%20where%20type%20%3D~%20%27microsoft.compute%2Fvirtualmachines%27%0A%7C%20project%20vmId%20%3D%20tolower%28id%29%2C%20vmNics%20%3D%20properties.networkProfile.networkInterfaces%0A%7C%20join%20%28%0A%20%20Resources%20%7C%0A%20%20where%20type%20%3D~%20%27microsoft.network%2Fnetworkinterfaces%27%20%7C%0A%20%20project%20nicVMId%20%3D%20tolower%28tostring%28properties.virtualMachine.id%29%29%2C%20allVMNicID%20%3D%20tolower%28id%29%2C%20nicIPConfigs%20%3D%20properties.ipConfigurations%29%0A%20%20on%20%24left.vmId%20%3D%3D%20%24right.nicVMId%0A%7C%20join%20%28%0A%20%20Resources%0A%20%20%7C%20where%20type%20%3D~%20%27microsoft.network%2Fpublicipaddresses%27%20and%20isnotnull%28properties.ipConfiguration.id%29%0A%20%20%7C%20where%20sku.name%20%3D%3D%20%27Basic%27%0A%20%20%7C%20project%20pipId%20%3D%20id%2C%20pipSku%20%3D%20sku.name%2C%20pipAssociatedNicId%20%3D%20tolower%28tostring%28split%28properties.ipConfiguration.id%2C%20%27%2FipConfigurations%2F%27%29%5B0%5D%29%29%29%0A%20%20on%20%24left.allVMNicID%20%3D%3D%20%24right.pipAssociatedNicId%0A%7C%20project%20vmId%2C%20pipId%2C%20pipSku" target="_blank">portal.azure.cn</a>
6650

6751
---

articles/governance/resource-graph/samples/samples-by-table.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ details, see [Resource Graph tables](../concepts/query-language.md#resource-grap
7373

7474
[!INCLUDE [azure-resource-graph-samples-table-resources](../../../../includes/resource-graph/samples/bytable/resources.md)]
7575

76+
[!INCLUDE [virtual-machine-basic-sku-public-ip](../../includes/resource-graph/query/virtual-machine-basic-sku-public-ip.md)]
77+
7678
## SecurityResources
7779

7880
[!INCLUDE [azure-resource-graph-samples-table-securityresources](../../../../includes/resource-graph/samples/bytable/securityresources.md)]

0 commit comments

Comments
 (0)