Last active
July 21, 2021 09:05
-
-
Save pmarques/4cda638d6a5296050d98dc62fd221411 to your computer and use it in GitHub Desktop.
Azure Resource Graph Queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Number of VMs by PowerState | |
// Filter per: | |
// * Management Group | |
// * Tags | |
Resources | |
| where type =~ 'Microsoft.Compute/virtualMachines' | |
| where tags.service =~ "svc1" and tags.application in~ ("app1", "app2") | |
| join kind=inner ( | |
ResourceContainers | |
| where type == "microsoft.resources/subscriptions" and properties.managementGroupAncestorsChain[0].name in ("staging", "prod") | |
| project subscriptionId | |
) on subscriptionId | |
| extend powerState = tostring(properties.extended.instanceView.powerState.code) | |
| summarize count() by powerState |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment