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