Azure / Azure/azure-cli

az vm get-instance-view not returning list when providing one ID

Open
#28,205 3 comments 0 reactions 2 assignees Claimed by @zhoxing-ms View on GitHub
act-observability-squad Auto-Assign Auto-Resolve Azure CLI Team Compute customer-reported question Similar-Issue
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

According [this documentation](https://learn.microsoft.com/en-us/cli/azure/query-azure-cli?tabs=concepts%2Cbash#dictionary-and-list-cli-results), commands which COULD return more than one object should return an array.

`az vm get-instance-view --ids "$MY_IDS"`

* Returns an array with objects when $MY_IDS contains more than one value.
* Returns an object when $MY_IDS contains a single value

This makes queries unreliable. For example: `az vm get-instance-view --ids "$MY_IDS" --query "[].id"`

### Related command

`az vm get-instance-view`

### Errors

No errors

### Issue script & Debug output

After having a look at them I don't think they are relevant. Please let me know if actually required and I will spare some time to remove all the sensitive information and provide the logs.

### Expected behavior

`az vm get-instance-view --ids "my-vm-id"` returns an array with a single object

### Environment Summary

```
azure-cli 2.56.0

core 2.56.0
telemetry 1.1.0

Extensions:
azure-devops 0.26.0
bastion 0.3.0

Dependencies:
msal 1.24.0b2
azure-mgmt-resource 23.1.0b2

Python location '/opt/az/bin/python3'
Extensions directory '/home//.azure/cliextensions'

Python (Linux) 3.11.5 (main, Jan 8 2024, 09:08:51) [GCC 9.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.
```
### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.