Azure Resource Graph IV – „Where“ and string operators

Querying data needs always filtering capabilities. ARG, has a powerful query language that allows complex queries with just a few characters of typework.  Knowing how to filter data is importtant, so that you can use the power of the ARG engine before you retrieve the data to your session (PowerShell in that case), especially with large datasets. This article explains the filter options provided by ARG.

The ‚where‘ statement has nine main operators to work with.

List of main ‚where‘ operators:

  • = – equals
  • has – whole term
  • hasprefix – whole term has prefix
  • hassuffix – whole term has suffix
  • contains – string contains
  • startswith – string starts with
  • endswith – string ends with
  • matches regex
  • in – string array contains string element

When we combine the operators with teh case sensitive and negation options, we can see a lot of options to filter data. See below.

string operator
case insensitive
negatedcase insensitive
and negated

==~!=!~
hashas_cs!has!has_cs
hasprefixhasprefix_cs!hasprefix!hasprefix_cs
hassuffixhassuffix_cs!hassuffix
!hassuffix_cs
containscontains_cs!contains!contains_cs
startswithstartswith_cs!startswith!startswith_cs
endswithendswith_cs!endswith!endswith_cs
matchregex



in!in

This leads to 31(!) possibilities, now lets start with a query of all resource tags in the database

The output is a list of objects this (name,tags):

Now lets play around with the „where“ statement.

I hope you got enough examples and info sto start on your own!

Happy experimenting !

R.