Closed alexeyshishkin01 closed 1 year ago
@alexeyshishkin01 Thanks for the feedback! I have assigned the issue to content author to check and update the document as appropriate.
@dlepow Can you please check and add your comments on this doc update request as applicable.
@alexeyshishkin01 - Thanks for the question. The scheduling feature allows you to run any ACR task with a timer trigger. The task could run a command (as shown in the article), build an image, push an image, etc.
Example to build and push an image using timer trigger (only) from task YAML file in Azure-Samples repo:
az acr task create -n hello-world -r <your registry> --schedule "dailyTimer:0 12 * * Mon-Fri" --commit-trigger-enabled false -c https://github.com/Azure-Samples/acr-tasks.git -f build-push-hello-world.yaml
One detail here is to disable the source code commit trigger, which is enabled by default.
Based on your question and the example in the article, I see that the entry in table of contents could seem misleading, so will plan to update it to something like "Run task on a schedule" or similar.
Please let us know if this helps.
thanks, @dlepow
my case is much simpler, but the documentation is not so easy to understand
so, I have only Dockerfile and no github context
I can build and push the image manually as describe in the article - https://docs.microsoft.com/en-us/azure/container-registry/container-registry-quickstart-task-cli
I need to create a task so that the image is build on a schedule only (no triggers required), say once a week Is it possible to do it via 'az acr create' command ?
I've tried to do it the following way:
az acr task create \ --name task-build-$image_id \ --image $image_id:$tag_id \ --registry my_registry \ --context /dev/null \ --arg PGPRO_MAJOR_VERSION=$pgpro_major_version \ --arg PGPRO_FULL_VERSION=$pgpro_full_version \ --no-cache \ --no-push \ --file Dockerfile-pgpro-ent-debian-x64 \ --base-image-trigger-enabled false \ --commit-trigger-enabled false \ --schedule "40 "
az acr task run \ --name task-build-$image_id \ --registry my_registry
but got the enigmatic error:
Queued a run with ID: cg51 Waiting for an agent... 2021/04/01 15:00:09 Alias support enabled for version >= 1.1.0, please see https://aka.ms/acr/tasks/task-aliases for more information. failed to unmarshal task before running: failed to deserialize task and validate: yaml: line 4: could not find expected ':'
Run ID: cg51 failed after 1s. Error: failed during run, err: exit status 1
then I've tried to use yaml-file:
az acr task create \ --name task-build-$image_id \ --registry pgprostdacr \ --context /dev/null \ --no-cache \ --no-push \ --file pgpro-ent.yaml \ --base-image-trigger-enabled false \ --commit-trigger-enabled false \ --schedule "40 "
az acr task run --name task-build-$image_id --registry pgprostdacr
Queued a run with ID: cg52 Waiting for an agent... 2021/04/01 21:57:26 Alias support enabled for version >= 1.1.0, please see https://aka.ms/acr/tasks/task-aliases for more information. 2021/04/01 21:57:26 Creating Docker network: acb_default_network, driver: 'bridge' 2021/04/01 21:57:26 Successfully set up Docker network: acb_default_network 2021/04/01 21:57:26 Setting up Docker configuration... 2021/04/01 21:57:27 Successfully set up Docker configuration 2021/04/01 21:57:27 Logging in to registry: pgprostdacr.azurecr.io
2021/04/01 21:57:43 Successfully logged into pgprostdacr.azurecr.io 2021/04/01 21:57:43 Executing step ID: acb_step_0. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network' 2021/04/01 21:57:43 Scanning for dependencies... 2021/04/01 21:57:43 Output from dependency scanning: fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). error opening dockerfile: Dockerfile-pgpro-ent-debian-x64, error: open Dockerfile-pgpro-ent-debian-x64: no such file or directory failed to run step ID: acb_step_0: failed to scan dependencies: exit status 1
Run ID: cg52 failed after 19s. Error: failed during run, err: exit status 1
what do I do wrong ?
The document doesn't require an update.
Solution There maybe a solution if you don't provide any context when creating the task, but it cannot be a scheduled task because you always need a context when running the job. You can create a task without context and providing the context when you manually run it.
# Create a task, use a yaml file for your task.
az acr task create \
--name nocontext \
--registry $ACR_NAME \
--context /dev/null \
--file task.yaml \
--base-image-trigger-enabled false \
--commit-trigger-enabled false \
# Run the task manually.
az acr task run -n nocontext --registry $ACR_NAME --context .
You can check the context argument by running az acr task create -h
for detail if you want to run a scheduled job.
the title of the article of the contents is '4 - Build on a schedule', which implies building of images when you click on the article link the title changes to 'Tutorial: Run an ACR task on a defined schedule' but the article does not cover building topic, it's all about running already built images
so, my question is how to build images on a schedule ? say, no other triggers for building an images except a schedule ?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.