skip to Main Content

I am trying to create a scheduled ACR task to delete old images from storage using this command:

PURGE_CMD="acr purge --filter 'worker:.*' --untagged --ago 1d"
 az acr task create --name remove_old_images_worker --cmd "$PURGE_CMD" --schedule
 "0 0 * * *" --registry registry --context /dev/null

But it returns me an error with this:

acb.yaml does not exist.

And what is also interesting is that it worked for a similar task just a couple of days ago.

2

Answers


  1. Chosen as BEST ANSWER

    After some investigation, I solved this problem using Terraform as follows:

    resource "azurerm_container_registry_task" "acr_purge_task" {
      name                  = "scheduledAcrPurgeTask"
      container_registry_id = azurerm_container_registry.registry.id
      platform {
        os           = "Linux"
        architecture = "amd64"
      }
      encoded_step {
        task_content = <<EOF
        version: v1.1.0
        steps:
        - cmd: acr purge --filter '.*:^((?!prod|dev).)*$' --untagged --ago 7d
        disableWorkingDirectoryOverride: true
        timeout: 3600
        EOF
      }
      agent_setting {
        cpu = 2
      }
      timer_trigger {
        name     = "t1"
        schedule = "0 0 * * Tue"
        enabled  = true
      }
    }
    

  2. The error message "acb.yaml does not exist" implies that the Azure CLI is expecting to find an acb.yaml file in the context location you’ve specified. If you’re specifying /dev/null as the context, it’s unclear why the CLI would expect to find a file there unless there’s a bug or a temporary issue with the CLI or the ACR service. When creating scheduled tasks in Azure Container Registry (ACR) using the Azure CLI, the --context parameter is used to specify the location of the source code, which typically contains a acb.yaml

    However, for a purge task that only runs a command without needing a build context, you should use the special value --context /dev/null.

    Instead of using /dev/null, try using a dummy context with an empty acb.yaml file:

    mkdir dummy-context
    

    enter image description here

    touch dummy-context/acb.yaml
    

    enter image description here

    az acr task create 
      --name remove_old_images_worker 
      --registry <registryname>
      --cmd "$PURGE_CMD" 
      --schedule "0 0 * * *" 
      --context /dev/null 
      --commit-trigger-enabled false 
      --pull-request-trigger-enabled false
    

    enter image description here

    Needless to say below things must be ensured first.

    • the necessary permissions to create tasks in the ACR.
    • latest version of the Azure CLI installed
    • there are no typos or missing arguments in the command
    • have you reached a limit on the number of tasks you
      can create in your ACR.

    Additionally, make sure that you are running the command in the correct directory where the acb.yaml file is located. If you are running the command from a different directory, you may need to specify the full path to the acb.yaml file using the --context parameter.

    References:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search