@@ -22,12 +22,16 @@ Resources
22
22
```
23
23
Resources
24
24
| where type =~ 'Microsoft.Compute/virtualMachines'
25
+ | extend ServiceOwner = tostring(tags['Service Owner'])
26
+ | extend ServiceName = tostring(tags['Service Name'])
27
+ | extend CostCodeID = tostring(tags['Cost Code ID'])
25
28
| join kind=leftouter (ResourceContainers | where type=~'microsoft.resources/subscriptions'
26
29
| project SubName=name, subscriptionId) on subscriptionId
27
30
| project subscriptionId, name, resourceGroup, location,
28
31
vmSize = tostring(properties.hardwareProfile.vmSize),
29
32
osType = tostring(properties.storageProfile.osDisk.osType),
30
- hostId = tostring(properties.host.id), tags, id
33
+ hostId = tostring(properties.host.id), tags, id,
34
+ ServiceOwner,ServiceName,CostCodeID
31
35
```
32
36
33
37
303
307
Until ($r.Count -lt 1000)
304
308
```
305
309
310
+ ## List all Resource Groups with Subordinate Cost Code ID
311
+ ```
312
+ resourcecontainers
313
+ | where type == "microsoft.resources/subscriptions/resourcegroups"
314
+ | extend ServiceOwner = tostring(tags["Service Owner"])
315
+ | extend ServiceName = tostring(tags["Service Name"])
316
+ | extend CostCodeID = tostring(tags["Cost Code ID"])
317
+ | join kind=inner (Resources | where tags contains "Cost Code ID" | extend SubCostCodeID = tostring(tags["Cost Code ID"]) | project resourceGroup,SubordinateTags=tags,SubCostCodeID) on resourceGroup
318
+ | join kind=leftouter (ResourceContainers | where type=~'microsoft.resources/subscriptions'
319
+ | project SubName=name, subscriptionId) on subscriptionId
320
+ | project subscriptionId, SubName, resourceGroup, location, CostCodeID, ServiceOwner, ServiceName, tags,SubordinateTags, SubCostCodeID
321
+ ```
322
+
323
+ ## List all Resources WITHOUT 'Cost Code ID' tag
324
+ ```
325
+ Resources
326
+ | where tags !contains "Cost Code ID"
327
+ | join kind=leftouter (ResourceContainers | where type=~'microsoft.resources/subscriptions'
328
+ | project SubName=name, subscriptionId) on subscriptionId
329
+ | project subscriptionId, SubName, name, resourceGroup, location, tags, type
330
+ ```
331
+
332
+
333
+ ---
334
+ ## Using PowerShell
335
+
336
+ ```
337
+ $q = "YOUR_KUSTO_QUERY"
338
+ $Results = Search-AzGraph -query $q -First 5000 ; write-host "$($Results.Count) entries"
339
+ $Results | Out-GridView # Or Export-CSV
340
+ ```
306
341
307
342
---
308
343
## References
0 commit comments