Azure / Azure/azure-cli

[Core]--add option is very hard to use

Open
#17,610 1 comment 0 reactions 2 assignees Claimed by @jiasli View on GitHub
act-platform-engineering-squad Core feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

--add option is very difficult to use. It supports 2 kinds of arguments: JSON format and key=value format.
**JSON format**
For JSON format, there are many restrictions which will hinder customers running the command successfully:
1、How to pass multiple values one time: each item should be separated by a space, instead of passing a JSON array directly.
2、Special characters should be escaped. In Linux bash, single quotes can be used to deal the problem. But in PS and cmd, every special character has to be escaped such as quotation marks, parenthes, and space

**command example** :
`az sig image-version update`

**right example in Linux bash**:
`az sig image-version update --no-wait -g myresourcegroup --gallery-name mygalleryname --gallery-image-definition images1 --gallery-image-version 1.2021.03311859 --add publishingProfile.targetRegions '{"name":"koreacentral","regionalReplicaCount": 3, "storageAccountType": "Standard_LRS"}' '{"name":"francecentral","regionalReplicaCount": 3, "storageAccountType": "Standard_LRS"}'`

**wrong example** (passing a JSON list directly)
`az sig image-version update --no-wait -g myresourcegroup --gallery-name mygalleryname --gallery-image-definition mycustomimage --gallery-image-version 1.2021.03311859 --add publishingProfile.targetRegions [{"name":"koreacentral","regionalReplicaCount":3,"storageAccountType":"Standard_LRS"},{"name":"canadacentral","regionalReplicaCount":3,"storageAccountType":"Standard_LRS"},{"name":"francecentral","regionalReplicaCount":3,"storageAccountType":"Standard_LRS"}]`

**right example in PS**:
`az sig image-version update --no-wait -g myresourcegroup --gallery-name mygalleryname --gallery-image-definition mycustomimage --gallery-image-version 1.2021.03311859 --add publishingProfile.targetRegions {\"name\":\"koreacentral\",\"regionalReplicaCount\":3,\"storageAccountType\":\"Standard_LRS\"} {\"name\":\"canadacentral\",\"regionalReplicaCount\":3,\"storageAccountType\":\"Standard_LRS\"}`

**wrong example in PS** (with space in JSON object):
`az sig ... --add publishingProfile.targetRegions {\"name\": \"centraluseuap\", \"regionalReplicaCount\":3,\"storageAccountType\":\"Standard_LRS\"}`

**key=value format**
For key value pair format, customers have to run the command many times for multiple items, which will be executed sequentially and not meets customers requirements.

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.