--query for az resource show output result on different lines
See original GitHub issueDescription
When I running command
az resource show --id "$ID" --query [id,location] --o tsv
the result is shown on two separate lines:
/subscriptions/103d4c24-9f75-4f53-9477-9b01242c7a58/resourceGroups/group/providers/microsoft.insights/components/appname
East US
How can I make it output in a table format? Why when I do a similar --query
for the list of items - id and location forming a single line?
Environment summary
Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here:
Cloud Shell
CLI Version: What version of the CLI and modules are installed? (Use az --version
)
Answer here:
ergey@Azure:~$ az --version
azure-cli (2.0.9)
acr (2.0.7)
acs (2.0.9)
appservice (0.1.9)
batch (3.0.2)
billing (0.1.2)
cdn (0.0.5)
cloud (2.0.5)
cognitiveservices (0.1.5)
command-modules-nspkg (2.0.0)
component (2.0.6)
configure (2.0.9)
consumption (0.1.2)
core (2.0.10)
cosmosdb (0.1.9)
dla (0.0.9)
dls (0.0.9)
feedback (2.0.5)
find (0.2.5)
interactive (0.3.5)
iot (0.1.8)
keyvault (2.0.7)
lab (0.0.7)
monitor (0.0.7)
network (2.0.9)
nspkg (3.0.0)
profile (2.0.7)
rdbms (0.0.4)
redis (0.2.6)
resource (2.0.9)
role (2.0.7)
sf (1.0.4)
sql (2.0.6)
storage (2.0.9)
vm (2.0.9)
Python (Linux) 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609]
Python location '/usr/bin/python'
OS Version: What OS and version are you using?
Answer here:
windows hosting the edge browser
Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here:
bash
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
JMESPath query command results with Azure CLI
Before introducing queries, take a look at the unmodified output of the az vm show command: Bash; PowerShell; Cmd. Azure CLI Copy.
Read more >How to query Azure resources using the Azure CLI
Change the output type using the --output argument. In the following example the output type of table is used. You can see that...
Read more >AZ CLI query filter on multiple properties using && - Stack ...
I am trying to create an az cli query that can evaluate if I am logged into the correct tenant and subscription.
Read more >Setting the AWS CLI output format - AWS Documentation
You can combine the --query option with the table format to display a set of elements preselected from the raw output. Notice the...
Read more >JMESPATH queries - Azure Citadel
Each of the commands below follow az resource list --resource-group myAppRG-Staging --query '<query>' --output json format. Only the query switch will be shown...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SergeyKanzhelev to select properties and form a table, the correct way is to project each item in the list to a dict, which is
--query [*].{name:name,resourceGroup:resourceGroup}
.There are more examples in http://jmespath.org/. We relies on JMESPath to transform the json results.
Thank you! So my understanding is that this thing
az resource list --namespace microsoft.insights --resource-type components --query [*].[id,location]
returns the array of arrays. So--out tsv
will make every nested array a row and all elements of nested array is a separate column. When this commandaz resource show --id "$ID" --query [id,location] --o tsv
returns an array of strings. So--out tsv
makes every element of it a separate row.