Add "exists" subcommand
Related command
az
Is your feature request related to a problem? Please describe. It's easy to get back information about most Azure resources using list or show, but when those resource don't exist, you get back an error. This breaks automation scripts.
Describe the solution you'd like Along with list/show, add a subcommand for "exists" that will return either a 0 or 1 based upon if the resource exists.
Describe alternatives you've considered I have used things like:
exists=$(az synapse workspace list --resource-group $rg -o tsv --query "[?name=='$workspacename'] | length(@)")
Additional context I realize that the Azure CLI commands are supposed to always be idempotent, so I should be able to just do a "create" on anything and it won't break existing resources. The problem is that most of the time Azure CLI will return an error saying something like "resource already exists". This breaks automation scripts all the time. The cleanest solution, to me, would be to just give us an option for "exists" to get 0/1.
Az Pwsh already kinda does this, as it will return an empty object when you do the Get. This is totally workable, too, if Azure CLI just returned nothing.
route to CXP team
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @wonner, @zesluo.
Issue Details
Related command
az
Is your feature request related to a problem? Please describe. It's easy to get back information about most Azure resources using list or show, but when those resource don't exist, you get back an error. This breaks automation scripts.
Describe the solution you'd like Along with list/show, add a subcommand for "exists" that will return either a 0 or 1 based upon if the resource exists.
Describe alternatives you've considered I have used things like:
exists=$(az synapse workspace list --resource-group $rg -o tsv --query "[?name=='$workspacename'] | length(@)")
Additional context I realize that the Azure CLI commands are supposed to always be idempotent, so I should be able to just do a "create" on anything and it won't break existing resources. The problem is that most of the time Azure CLI will return an error saying something like "resource already exists". This breaks automation scripts all the time. The cleanest solution, to me, would be to just give us an option for "exists" to get 0/1.
Az Pwsh already kinda does this, as it will return an empty object when you do the Get. This is totally workable, too, if Azure CLI just returned nothing.
| Author: | chlsmith |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
Hi @chlsmith, Thanks for the suggest. I think you can use az synapse workspace check-name instead of exists.