Skip to content

Instantly share code, notes, and snippets.

@apgapg
Last active March 2, 2022 03:25
Show Gist options
  • Save apgapg/d3ca88d3b61fdb7c3719ece40725dc38 to your computer and use it in GitHub Desktop.
Save apgapg/d3ca88d3b61fdb7c3719ece40725dc38 to your computer and use it in GitHub Desktop.
VS code Script that purges old acr images and retains latest 5
# This vs code script purges the old images in 'acr' (Azure Container Registry) via 'az' cli.
# Retains only latest 5 in a particular repository
# You need to change 'myacr' with your acr name and 'mysubs' with your subscription name.
# Make sure az cli is installed and logged in.
#
# Read more: https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auto-purge
# azcli: https://github.com/Microsoft/vscode-azurecli
# List subscriptions
az account list --output table
# Set DMS subscription
az account set --name "mysubs"
# Check account
az account show
# Dry run purge acr 'server acr'
az acr run --cmd "acr purge --dry-run --keep=5 --filter 'server:.*' --ago 0d" --registry myacr /dev/null
# Run actual cmd for server acr
az acr run --cmd "acr purge --keep=5 --filter 'server:.*' --ago 0d" --registry myacr /dev/null
@apgapg
Copy link
Author

apgapg commented Mar 2, 2022

You can use individual commands in terminal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment