Created
May 19, 2020 14:20
-
-
Save rithala/d015d125c355525e5201ba5472f834b0 to your computer and use it in GitHub Desktop.
Purge Azure Container Repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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