# ACR Task Walkthrough

ACR Tasks provide a container centric compute primitive, focused on building and patching containers. This doc covers a walkthrough to understand the capabilities of ACR Tasks.

# ACR Task Execution Model

ACR Tasks take advantage of the container execution and isolation model, enabling customers to run any series of containers as commands across a common directory. ACR Tasks provide a common context and conditional/dependency flow between steps providing primitive, yet robust scenarios. By deferring the execution to containers, ACR Tasks has minimal dependencies between the Task execution environment and the code within a container.

Using containers as a collection of commands; developers may use any language or framework they desire, running on Linux or Windows operating systems, minimizing version dependency.

# Task Step Types

ACR Tasks supports three step types:

  • build containers using familiar syntax of docker build
  • push supports docker push of newly built or re-tagged images to a registry, including ACR, Docker hub and other private registries.
  • cmd to run a container as a command, enabling parameters passed to the containers [ENTRYPOINT]. cmd supports run parameters including volumes and other familiar docker run parameters, enabling unit and functional testing with concurrent container execution.

# Running Samples

Samples referenced use az acr run and assume a default registry is configured.

  • Configure a default registry

    Assuming your registry is named yourRegistry.azurecr.io, run the following

    az configure --defaults acr=yourRegistry
    
    1

Note: As of 9/9/18, az acr run is not yet public. Replace az acr run with az acr build, using the -f parameter to reference the task.yaml file.

# Building A Single Image

Using ACR Build (opens new window), users can easily build and optionally push single images.

az acr build -t hello-world:{{.Build.ID}} https://github.com/Azure-Samples/acr-build-helloworld-node.git
1

The equivalent ACR task would involve:

version: 1.0-preview-1
steps:
  - build: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} .
  - push: ["{{.Run.Registry}}/hello-world:{{.Run.ID}}"]
1
2
3
4

The task.yaml version does the following:

  • breaks up build and push into separate steps
  • changes Build.ID to Run.ID to better represent a run, which may do many things, in addition to docker build
  • provides a fully qualified reference to the target registry using Run.Registry. ACR Tasks supports pushing images to other registries.

To test the above yaml, run the following command in cloud shell (opens new window) or any other bash environment.

az acr run -f build-push-hello-world.yaml https://github.com/azure-samples/acr-tasks.git
1

# WORK IN PROGRESS ---

[!div class="nextstepaction"]