Azure / Azure/azure-cli

--ids argument documentation is incorrect

Open
#29,502 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

`az vm show --help` includes this:

```
Resource Id Arguments
--ids : One or more resource IDs (space-delimited). It should be a complete
resource ID containing all information of 'Resource Id' arguments. You
should provide either --ids or other 'Resource Id' arguments.
```

Note that it says space-delimited. However using spaces between resource IDs is not enough, newlines have to be used.

Example:
```
$ az vm show --ids '/subscriptions//resourceGroups//providers/Microsoft.Compute/virtualMachines/ /subscriptions//resourceGroups//providers/Microsoft.Compute/virtualMachines/'

missing VM NAME2

$ az vm show --ids "(echo -e /subscriptions//resourceGroups//providers/Microsoft.Compute/virtualMachines/\\n/subscriptions//resourceGroups//providers/Microsoft.Compute/virtualMachines/)"

```

Some other commands completely fail with confusing error messages when `--ids` are not newline delimited. Basically using `tsv` output ID from various list commands works here.

### Related command

az vm show, az vm start etc

### Errors

When used with `az vm start --ids`:

(ResourceNotFound) The Resource 'Microsoft.Compute/virtualMachines/ ' under resource group '' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Code: ResourceNotFound
Message: The Resource 'Microsoft.Compute/virtualMachines/ ' under resource group '' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

### Issue script & Debug output

This is I think the important part where for example vm start fails:
```
urllib3.connectionpool: https://management.azure.com:443 "POST /subscriptions//resourceGroups//providers/Microsoft.Compute/virtualMachines/%20/start?api-version=2022-11-01 HTTP/1.1" 404 235
```

It encodes the space and uses it as part of resource name it's requesting

### Expected behavior

Either of the following would be acceptable:
* Update documentation to make it clear that newlines are required as separators
* Actually accept spaces between resource IDs

### Environment Summary

```
$ az --version
azure-cli 2.60.0 *

core 2.60.0 *
telemetry 1.1.0

Dependencies:
msal 1.28.0
azure-mgmt-resource 23.1.0b2
```

### 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.