Expose --tag command to delete all resources that have a tag.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Is your feature request related to a problem? Please describe.**
A convenient way to delete all resources with a specific tag.
**Describe the solution you'd like**
`az resource delete --tag # deletes all resources that have a specific tag.`
`az vm delete --tag # deletes all VMs that have a specific tag.`
`az network vnet --tag # deletes all vnets that have a specific tag.`
Follow up from #4897
`az vm create ... --tags` applies tags to every resource it creates. Using this in conjunction with `az resource delete --tag` will not only delete the VM but every resource that was created to deploy the VM.
**Describe alternatives you've considered**
**Additional context**
- `az vm create's --tags` does not document that the tags are applied to every resource created via VM create. The parameter help should be updated.
- @tjprescott suggests implementing a delete_command() type to support tag-based deletion for any command.
- It might be good to restrict tag-based deletion to a resource group scope. So that resources with the same tag in another resource-group are not accidentally deleted.
Contributor guide
Assessment
This issue has not been assessed yet.