Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script is used for deleting old Azure Container Registry tags
#!/usr/bin/env bash
az login
az account set --subscription <subscription-id>
ACR_NAME=<acr-name>
REPO_NAME=<acr-repo-name>
OLD_IMAGE_TAGS=$(az acr repository show-tags --name $ACR_NAME --repository $REPO_NAME -o tsv)
for TAG in $OLD_IMAGE_TAGS;
do
if [[ $TAG == <some-prefix>* ]]; # Wildcard match. Remove this for deleting everything
then
echo "TAG: $TAG"
az acr repository delete -y --name $ACR_NAME --image $REPO_NAME:$TAG
fi
done
echo 'Finished!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment