Running containerized AzureDevOps pipeline agents in Azure Container Instances(ACI)


  • AzureDevOps tenant. Get one for free: Link
  • Azure Subscription. A free trial is available. (This is for hosting agent)

Microsoft describes here how you can host your own agent using Docker. We can use the same container (agent) and run it in Azure Container Instance.

I have pulled all the code for Docker and put it on a GitHub repository. Currently, it only supports Ubuntu 16.04 and Windows server core ltsc2019.

Docker images have been generated from these DockerFiles and pushed to a public repo on Docker Hub. We will use these images to create AzureDevOps pipeline agents.

Create a new Agent Pool in AzureDevOps tenant

Head over to your AzureDevOps tenant -> Organization settings -> Agent pools (under pipelines)

Add a new pool, name it “aci-pool”.

Get a PAT token

Go to User Settings -> Security -> “Personal access tokens” under your AzureDevOps tenant.

Create a new Token called “acipool” and grant “Read & manage” from “Agent Pools” tab.

Save the token some place safe as you won’t be able to see it again.

Spin up a container instance

From Azure portal, go to “Create a resource” and choose “Container Instances”.

Provide details as below and switch to networking tab.

Azure Portal – Container Instances – Create tab
Docker image: sparekh1/azpipeagents:ubuntu1604

You can modify above parameters as you need. Here we are creating a linux agent with 1 vcpu and 1 Gib memory. Notice the docker hub image name.

In networking tab, add port 443 which agent will use to communicate with AzureDevOps tenant. You can leave DNS name label empty.

In “Advanced” tab, provide below Environment variables

  • AZP_URL – Your tenant url. Ex:
  • AZP_TOKEN – PAT token
  • AZP_AGENT_NAME – azpipeagent-ubuntu-01. You can choose any name, I am keeping it same as name of the container.
  • AZP_POOL – Name of the pool. Here in our case it is ” aci-pool”. You can leave it empty to put agent into “Default” agent pool.
  • AZP_WORK – agent’s work directly. Default is _work

Container environment variables

That’s it. Press create and it will start creating the container. Once finished, you can check agent logs under “settings” -> “containers” -> “logs” for your ACI.

Check agent status

Back in aci-pool in your tenant, you can check agents tab to see your agent’s status

Now you can start using this agent in your Build/Release pipelines.

Testing agent

Add a new build definition. Add a “bash” task with inline command “uname -v“. Choose newly created agent pool as “Agent Pool” for build definition.

Check logs and we can see output from “uname -v

Scheduled start and stop ACI

Check out this post.


One thought on “Running containerized AzureDevOps pipeline agents in Azure Container Instances(ACI)

Leave a Reply

Your email address will not be published. Required fields are marked *