Skip to content

Instantly share code, notes, and snippets.

@ninjarobot
Created February 28, 2020 20:55
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 ninjarobot/d7375c1ffedd4ca1648ec5fe3ae10744 to your computer and use it in GitHub Desktop.
Save ninjarobot/d7375c1ffedd4ca1648ec5fe3ae10744 to your computer and use it in GitHub Desktop.
Cleanup ARM deployments
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: deployment-cleanup.sh <subscription_id> <resource_group>"
exit 1
fi
az group deployment list --subscription $1 -g $2 --query '[].{name:name,ts:properties.timestamp}[*].name' -o tsv | tail -n +100 | xargs -n1 az group deployment delete --subscription $1 -g $2 -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment