Created
September 7, 2021 07:53
-
-
Save mbaykara/ac8c37cc8d304025895165ef71e51a8b to your computer and use it in GitHub Desktop.
Clean Azure Container Registry
This file contains 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
# !/bin/env bash | |
echo "This script deletes data!" | |
REGISTRY=production | |
size=$(az acr repository list -n $REGISTRY -u $USER -p $PASSWORD | jq length --) | |
for i in `seq 1 $size`; | |
do | |
tmp=$(az acr repository list -n $REGISTRY -u $USER -p $PASSWORD | jq .[$i]) | |
REPOSITORY=$(echo $tmp | sed 's/"//g') | |
echo "Cleaning repository: $REPOSITORY" | |
##if you are sure with deleted task then remove --dry-run arg | |
PURGE="acr purge --filter "$REPOSITORY:^.*dev.*$" --filter "$REPOSITORY:^.*remove.*$" --filter "$REPOSITORY:^.*umxmig.*$" --untagged --ago --dry-run 30d" | |
az acr run --cmd "$PURGE" --timeout 3600 --registry $REGISTRY /dev/null | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment