forked from carmada-dev/demo-images
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcleanup.sh
29 lines (22 loc) · 794 Bytes
/
cleanup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
usage() {
echo "======================================================================================"
echo "Usage: $0"
echo "======================================================================================"
echo " -s [OPTIONAL] The target subscription's name or id"
exit 1;
}
SUBSCRIPTION="$(az account show --query id -o tsv)"
while getopts 's:' OPT; do
case "$OPT" in
s)
SUBSCRIPTION="${OPTARG}" ;;
*)
usage ;;
esac
done
clear
while read RESOURCEGROUP; do
echo "Deleting resource group '$RESOURCEGROUP' ..."
az group delete --resource-group $RESOURCEGROUP --force-deletion-types 'Microsoft.Compute/virtualMachines' --no-wait --yes
done < <(az group list --subscription "$SUBSCRIPTION" --query "[?starts_with(name, 'PKR-')].name" -o tsv)