You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/governance/resource-graph/concepts/explore-resources.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Resources
27
27
| limit 1
28
28
```
29
29
30
-
```azurecli-interactive
30
+
```azurecli
31
31
az graph query -q "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | limit 1"
32
32
```
33
33
@@ -122,7 +122,7 @@ Resources
122
122
| summarize count() by location
123
123
```
124
124
125
-
```azurecli-interactive
125
+
```azurecli
126
126
az graph query -q "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location"
127
127
```
128
128
@@ -164,7 +164,7 @@ Resources
164
164
| project name, resourceGroup
165
165
```
166
166
167
-
```azurecli-interactive
167
+
```azurecli
168
168
az graph query -q "Resources | where type =~ 'Microsoft.Compute/virtualMachines' and properties.hardwareProfile.vmSize == 'Standard_B2s' | project name, resourceGroup"
169
169
```
170
170
@@ -185,7 +185,7 @@ Resources
185
185
| project disk.id
186
186
```
187
187
188
-
```azurecli-interactive
188
+
```azurecli
189
189
az graph query -q "Resources | where type =~ 'Microsoft.Compute/virtualmachines' and properties.hardwareProfile.vmSize == 'Standard_B2s' | extend disk = properties.storageProfile.osDisk.managedDisk | where disk.storageAccountType == 'Premium_LRS' | project disk.id"
190
190
```
191
191
@@ -225,7 +225,7 @@ record would be returned and the **type** property on it provides that detail.
225
225
> [!NOTE]
226
226
> For this example to work, you must replace the ID field with a result from your own environment.
227
227
228
-
```azurecli-interactive
228
+
```azurecli
229
229
az graph query -q "Resources | where type =~ 'Microsoft.Compute/disks' and id == '/subscriptions/<subscriptionId>/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/disks/ContosoVM1_OsDisk_1_9676b7e1b3c44e2cb672338ebe6f5166'"
230
230
```
231
231
@@ -274,7 +274,7 @@ virtual machines. Then the queries use the list of NICs to find each IP address
274
274
public IP address and store those values. Finally, the queries provide a list of the public IP
275
275
addresses.
276
276
277
-
```azurecli-interactive
277
+
```azurecli
278
278
# Use Resource Graph to get all NICs and store in the 'nics.txt' file
279
279
az graph query -q "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | project nic = tostring(properties['networkProfile']['networkInterfaces'][0]['id']) | where isnotempty(nic) | distinct nic | limit 20" --output table | tail -n +3 > nics.txt
280
280
@@ -293,7 +293,7 @@ $nics.nic
293
293
Use the file (Azure CLI) or variable (Azure PowerShell) in the next query to get the related network
294
294
interface resources details where there's a public IP address attached to the NIC.
295
295
296
-
```azurecli-interactive
296
+
```azurecli
297
297
# Use Resource Graph with the 'nics.txt' file to get all related public IP addresses and store in 'publicIp.txt' file
298
298
az graph query -q="Resources | where type =~ 'Microsoft.Network/networkInterfaces' | where id in ('$(awk -vORS="','" '{print $0}' nics.txt | sed 's/,$//')') | project publicIp = tostring(properties['ipConfigurations'][0]['properties']['publicIPAddress']['id']) | where isnotempty(publicIp) | distinct publicIp" --output table | tail -n +3 > ips.txt
299
299
@@ -312,7 +312,7 @@ $ips.publicIp
312
312
Last, use the list of public IP address resources stored in the file (Azure CLI) or variable (Azure
313
313
PowerShell) to get the actual public IP address from the related object and display.
314
314
315
-
```azurecli-interactive
315
+
```azurecli
316
316
# Use Resource Graph with the 'ips.txt' file to get the IP address of the public IP address resources
317
317
az graph query -q="Resources | where type =~ 'Microsoft.Network/publicIPAddresses' | where id in ('$(awk -vORS="','" '{print $0}' ips.txt | sed 's/,$//')') | project ip = tostring(properties['ipAddress']) | where isnotempty(ip) | distinct ip" --output table
0 commit comments