Skip to content

Instantly share code, notes, and snippets.

@joshgav
Last active September 27, 2018 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshgav/82c3fcad1daa39285f16a9496b850637 to your computer and use it in GitHub Desktop.
Save joshgav/82c3fcad1daa39285f16a9496b850637 to your computer and use it in GitHub Desktop.
Azure resource management helper shell scripts
declare prefix="azuregosdkjuglaptop"
# cleanup_groups requests deletion of groups with names starting with `prefix`
# it returns after request acceptance, i.e. it does not wait for deletion to actually finish
# `prefix` string "___": first letters of names of groups to delete
function cleanup_groups () {
declare prefix=${1:-"___"} # default to unlikely value for safety
# set up jmespath query
jmespath_query="[? starts_with(name, \`${prefix}\`)].name"
xargs_exec="xargs -L 1 -t -I {}"
az group list --query "$jmespath_query" --output tsv |
$xargs_exec az group delete --no-wait --yes --name {}
}
cleanup_groups $prefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment