Trying to query resources in Azure resource graph, but I cannot seem to get the wildcard working as intended. For example, AKS spins up a bunch of disk PVCs with the name "pvc-[some_guid]", which I am trying to eliminate from my query return. Any idea on how to accomplish this? The below query is the example I am using, I am attempting to return all names except the names with the "pvc-[some_guid] in them.
resources
| where type has "microsoft.compute/disks"
| extend diskState = tostring(properties.diskState)
| where diskState == 'Unattached'
| where name != "pvc-*"
| join kind=inner (
resourcecontainers
| where type == 'microsoft.resources/subscriptions'
| project subscriptionId, subscriptionName = name)
on subscriptionId
| project name, diskState, managedBy, subscriptionName, resourceGroup, location
Thought I could use the wildcard with the where name != "pvc-*", but that does not appear to be the case.
The
!=operator does not support wildcards. It will only match exact string values. To exclude disk names that start with "pvc-", you can use thestartswith()function instead.| where name !startswith "pvc-" : This line filters out disks whose names start with "pvc-".