How to fetch resource group name( with pattern matching) using Azurecli I set my az account to current subscription. And I am trying to fetch the resource name ending with (example "***kafka" ). How can i do it. 

I tried with az group list -n '***kafka'


  validation error: Parameter 'resource_group_name' must conform to the following pattern: '^[-\w\._\(\)]+$'.
There are at least two ways to achieve this.

First is to go with transforming json output to proper object for PowerShell as described in this thread:


how do you select just one property from an array of “results” from the Azure command 'az group list in powershell'?


Second it to use --query global parameter for Azure CLI:

az group list --query "[?contains(name,'kafka')].name"


But remember to use at least PowerShell 6.2 as previous versions have an issue:


powershell --query error #9047