Skip to content

Instantly share code, notes, and snippets.

@rithala
Created May 19, 2020 14:20
Show Gist options
  • Save rithala/d015d125c355525e5201ba5472f834b0 to your computer and use it in GitHub Desktop.
Save rithala/d015d125c355525e5201ba5472f834b0 to your computer and use it in GitHub Desktop.
Purge Azure Container Repository
# WARNING! This script deletes data!
# Run only if you do not have systems
# that pull images via manifest digest.
Param(
[Parameter(Mandatory=$true)]
$registry,
[Parameter(Mandatory=$true)]
$repository,
[switch]
$enableDelete
)
if ($enableDelete) {
az acr repository show-manifests --name $registry --repository $repository --query "[?tags[0]==null].digest" -o tsv `
| %{ az acr repository delete --name $registry --image $repository@$_ --yes }
} else {
Write-Host "No data deleted."
Write-Host "Add -enableDelete switch to enable image deletion."
az acr repository show-manifests --name $registry --repository $repository --query "[?tags[0]==null]" -o tsv
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment