az command to list storage accounts using --query runs in Azure Cloud Shell but fails when run locally.
Any idea why?
I am using:
Windows 10PC
Python version 3.9.1
AZ CLI: 2.23.0
Steps:
Run PowerShell as Admin
Login successfully with az login
Run following commands:
Works locally (Storage / no --query):
az storage account list --output tsv
Works locally (Container / with --query)
az container list --query "[?contains(name, 'mycontainer2')]" --output tsv
Fails locally / Works in Cloud Shell (Storage/ with --query):
az storage account list --query "[?contains(name,'terraformXX')].name" --output tsv
Exception:
].name was unexpected at this time.
C:\WINDOWS\system32> "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\..\python.exe" -IBm azure.cli storage account list --query [?contains(name,'terraformXX')].name --output tsv
The error suggests that some escape character is required. No luck finding a solution with escape characters + it works in Cloud Shell, so I think might be a misleading message.
Thanks in advance