acr-cli
acr-cli copied to clipboard
[general question] How to authenticate and run purge command using docker container
Hello, I'm trying to use acr-cli docker container to run unattended purge command against azure container registry behind the private endpoint (since it doesn't support acr tasks)
So I have docker build and can run it but wonder how can I execute the following commands in an unattended 👍
az acr login --name acr purge --filter 'image:.*' --ago 30d --untagged --dry-run
you can use:
az acr run \
--cmd "acr purge --filter 'image:.*' --ago 30d --untagged --dry-run" \
--registry myregistry \
/dev/null
acr tasks takes care of the login
I get an Error: unable to resolve authentication, missing identity token or password
when doing so with the latest revision. On 6fb5fa8fd7be62d80b5e0c0bc90f3b5faed02b07 it works. May it be a bug?
up
I have the same error, when trying to run acr:
(Note: I would prefer running it as a az acr run
-job, but the ACR firewall blocks it from completion)
az acr login --name=<registry-name> --expose-token | jq -r '.accessToken' | ./acr login --username= --password-stdin <registry-name>.azurecr.io
WARNING: You can perform manual login using the provided access token below, for example: 'docker login loginServer -u 00000000-0000-0000-0000-000000000000 -p accessToken'
Login Succeeded
./acr manifest list --repository <repo-name> --registry <registry-name>
Listing manifests for the "<repo-name>" repository:
<registry-name>.azurecr.io/<repo-name>@sha256:78b0ad60e71d2285a270abaf05ad6c2164d67f723eceebe3972f9d8278149590
./acr purge --registry=<registry-name> --filter '*/cache:.*' --ago 12h --untagged --dry-run
Error: unable to resolve authentication, missing identity token or password
This seems to work:
./acr purge --login --username= --password $ACR_TOKEN --registry=<registry-name>.azurecr.io --filter '*/cache:.*' --ago 12h --untagged --dry-run