Skip to content

Instantly share code, notes, and snippets.

@okanmenevseoglu
Created February 28, 2022 14:31
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 okanmenevseoglu/2d34652edadb11f2fe842804f10a85b7 to your computer and use it in GitHub Desktop.
Save okanmenevseoglu/2d34652edadb11f2fe842804f10a85b7 to your computer and use it in GitHub Desktop.
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