acr-cli icon indicating copy to clipboard operation
acr-cli copied to clipboard

[general question] How to authenticate and run purge command using docker container

Open rhollins opened this issue 4 years ago • 4 comments

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

rhollins avatar Feb 23 '21 15:02 rhollins

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

butzist avatar Feb 11 '22 08:02 butzist

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?

Himura2la avatar Oct 23 '22 05:10 Himura2la

up

Himura2la avatar May 02 '23 09:05 Himura2la

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

Richard87 avatar Oct 31 '23 14:10 Richard87