You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Question] Always returning an array from az resource show? #18423
The following command returns a single resource object
az resource show --ids {id_1}
The following command returns an array containing multiple resource objects
az resource show --ids {id_1} {id_2}
Is there an argument I can use to ensure that an array is returned, regardless of the number of ids supplied? I was wondering if it's possible with the --query flag, but I'm not familiar enough with JMESPath and couldn't spot anything obvious.
Anthony Martin (@anthony-c-martin) Sorry, when only one item is returned the output is an object,when multiple items are returned the output is an array, this is by designed for show command.
Does this output logic cause trouble for you to use JMESPath to parse the result? Could you control whether an object or an array is parsed according to the number of input parameters?
Anthony Martin (@anthony-c-martin) Sorry, when only one item is returned the output is an object,when multiple items are returned the output is an array, this is by designed for show command.
Does this output logic cause trouble for you to use JMESPath to parse the result? Could you control whether an object or an array is parsed according to the number of input parameters?
Thanks for the explanation! It's not a blocker - it would just be nice to have a one-liner script to share that doesn't require any complex logic to handle both cases.
Thanks for confirming this is not a blocker. As explained, this is by design for show commands: a single --ids value returns a single object and multiple values return an array. Since the question has been answered and you noted it is not blocking, I am closing this out.
Activity
yonzhan commentedon Jun 9, 2021
ARM
zhoxing-ms commentedon Jul 8, 2021
Anthony Martin (@anthony-c-martin) Sorry, when only one item is returned the output is an object,when multiple items are returned the output is an array, this is by designed for show command.
Does this output logic cause trouble for you to use JMESPath to parse the result? Could you control whether an object or an array is parsed according to the number of input parameters?
anthony-c-martin commentedon Jul 8, 2021
Thanks for the explanation! It's not a blocker - it would just be nice to have a one-liner script to share that doesn't require any complex logic to handle both cases.
teresaritorto commentedon Oct 12, 2026
Thanks for confirming this is not a blocker. As explained, this is by design for show commands: a single
--idsvalue returns a single object and multiple values return an array. Since the question has been answered and you noted it is not blocking, I am closing this out.