# Prerequisite
# 1) Install azure-cli curl, jq
registry="myregistry.azurecr.io"
scope_catalog="registry:catalog:*"
scope_repo_metadata="repository:*:metadata_read"
# Assume the client can login to azure using a managed identity
az login --identity
acr_refresh_token=$(az acr login --name $registry --expose-token | jq -r ".accessToken")
acr_access_token=$(curl -v -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=refresh_token&service=$registry&scope=$scope_catalog&scope=$scope_repo_metadata&refresh_token=$acr_refresh_token" https://$registry/oauth2/token | jq -r ".access_token")
# List repositories
repos=$(curl -H "Authorization: Bearer $acr_access_token" https://$registry/acr/v1/_catalog | jq -r ".repositories[]")
for repo in $repos; do
# List tags
curl -H "Authorization: Bearer $acr_access_token" https://$registry/acr/v1/$repo/_tags | jq -r ".tags"
done
Last active
March 9, 2023 08:02
-
-
Save northtyphoon/50afa1b3af324e9a202e7c4e36bce9c7 to your computer and use it in GitHub Desktop.