Here we can suggest that the environment was updated by Azure it seems so removing the availability of the acr command unless you explicitly specify running the task with the correct container image that contains the acr-cli.
To fix this when creating or updating ACR purge tasks we must let Azure use the official acr-cli container image, which has the acr binary installed and accessible during the task runtime.
please create the task again using the official ACR CLI container image to ensure the acr command is available:
PURGE_CMD="acr purge --filter '.*:master.*' --ago 5d --keep 10 --untagged && \
acr purge --filter '.*:-prod.*' --ago 5d --keep 10 --untagged && \
acr purge --filter '.*:app-prod.*' --ago 5d --keep 10 --untagged && \
acr purge --filter '.*:release-v.*' --ago 5d --keep 15 --untagged"
then , az acr task create \
--name scheduledPurgeNonMasterTask \
--registry myRegistry \
--cmd "$PURGE_CMD" \
--schedule "0 0 * * *" \
--context /dev/null
For purging tags and manifests in ACR using az acr run with acr purge: https://xtls-v4.hkg1.meaqua.org/en-us/azure/container-registry/container-registry-auto-purge
For running an ACR task on a defined schedule : https://xtls-v4.hkg1.meaqua.org/en-us/azure/container-registry/container-registry-tasks-scheduled
Try using an ACR task YAML file where you specify the image in the cmd step.
Exit code 125 is Docker's error code for invalid command syntax, returned when Docker cannot parse the arguments being passed to the docker run command.
So, when you use --image as an az acr task create parameter, the system tries to pass it directly to Docker's run command, which doesn't recognize it as a valid docker run option.
Let's try creating a file named for e.g. acr-purge-task.yaml (https://xtls-v4.hkg1.meaqua.org/en-us/azure/container-registry/container-registry-tasks-reference-yaml#acr-taskyaml-file-format)
YAML
version: v1.1.0
steps:
- cmd: mcr.microsoft.com/acr/acr-cli:latest
args:
- /bin/sh
- -c
- |
acr purge --filter '.*:master.*' --ago 5d --keep 10 --untagged && \
acr purge --filter '.*:-prod.*' --ago 5d --keep 10 --untagged && \
acr purge --filter '.*:app-prod.*' --ago 5d --keep 10 --untagged && \
acr purge --filter '.*:release-v.*' --ago 5d --keep 15 --untagged
Then create the task as below suggested:
Bash
az acr task create \
--name "scheduledPurgeOldProductionTask" \
--registry <registryname> \
--file <yourfilename.yaml> \
--context /dev/null \
--schedule "0 0 * * *"
After creating the task with the corrected syntax, test it:
Bash
az acr task run --name "scheduledPurgeOldProductionTask" --registry <registryname>
for e.g tried and it works adding for ref