I read this manual https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auto-purge
and use this script:
-
-
#!/bin/bash # WARNING! This script deletes data! # Run only if you do not have systems # that pull images via manifest digest. # Change to 'true' to enable image delete ENABLE_DELETE=false # Modify for your environment # TIMESTAMP can be a date-time string such as 2019-03-15T17:55:00. REGISTRY=dopsaks declare -a arr_REPOSITORYs=(\ "dev-api" \ "dev-ui" \ "sandbox-api" \ "sandbox-ui" \ "demo-api" \ "damo-ui" \ ) TIMESTAMP=2022-03-01 for REPOSITORY in "${arr_REPOSITORYs[@]}" do # Delete all images older than specified timestamp. if [ "$ENABLE_DELETE" = true ] then az acr repository show-manifests --name $REGISTRY --repository $REPOSITORY \ --orderby time_asc --query "[?timestamp < '$TIMESTAMP'].digest" -o tsv \ | xargs -I% az acr repository delete --name $REGISTRY --image $REPOSITORY@% --yes else echo "No data deleted." echo "Set ENABLE_DELETE=true to enable deletion of these images in $REPOSITORY:" az acr repository show-manifests --name $REGISTRY --repository $REPOSITORY \ --orderby time_asc --query "[?timestamp < '$TIMESTAMP'].[digest, timestamp, tags]" -o tsv fi done
-