0

I'm trying to query a list of soft-deleted Azure key vaults, then determine if the name of a specific key vault is listed.

 keyVaultName=whatever
 az keyvault list-deleted --query "[?contains(name, $keyVaultName)]" -o json

That produces the output...

az keyvault list-deleted: error: argument --query: invalid jmespath_type value: '[?contains(name,whatever)]'

So apparently I need to wrap that variable name in single quotes - but how? Is there some sort of string concatenation function?

awj
  • 7,482
  • 10
  • 66
  • 120

1 Answers1

1

The contains return true or false, the format is

boolean contains(array|string $subject, any $search)

You could try this

kv=nancykeyvault
az keyvault list-deleted --query "contains([].name,'$kv')"

enter image description here

Or, just wrap the variable in single quotes like this, it by default outputs as the JSON format.

az keyvault list-deleted --query "[?contains(name,'$kv')]"

enter image description here

Nancy
  • 26,865
  • 3
  • 18
  • 34