Last active
September 27, 2018 19:06
-
-
Save joshgav/82c3fcad1daa39285f16a9496b850637 to your computer and use it in GitHub Desktop.
Azure resource management helper shell scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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