-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add "exists" subcommand #23451
Copy link
Copy link
Open
Labels
Auto-AssignAuto assign by botAuto assign by botService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.Synapseact-codegen-extensibility-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.feature-request
Metadata
Metadata
Assignees
Labels
Auto-AssignAuto assign by botAuto assign by botService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.Synapseact-codegen-extensibility-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.feature-request
Related command
az list/show
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.