Run Self-Hosted Containerised Build Agents using Azure Container Instance and Azure DevOps
Running build agent in containers is a great solution for achieving flexibility and reducing the costs of maintaining build agents.
In this article, I will run through all the steps needed to start one.
Set up your Dockerfile
The first step is creating a folder containing a Dockerfile.
Create an Azure Container Registry
We then create an Azure Container Registry.
az group create --name buildagent --location uksouth
az acr create --resource-group buildagent --name alberto --sku Basic
Build the Dockerfile in the Cloud with a Task
We build our image using an Azure Registry Task.
az acr build --registry alberto -t buildagent:v1.0 --platform windows .
Create a Personal Access Token in Azure DevOps
In azure DevOps we create a personal access token that has “Read&Manage” permissions for “Agent Pools” and “Read&Execute” permission for “Build”.
We copy the token on a temporary location, we will need it soon!
Create an Agent Pool in Azure DevOps
Under “Organisation Settings” -> “Agent Pools” we create a new self-hosted agent.
Enable the Admin User in Azure Container Registry
The admin user can be enabled by running:
az acr update -n alberto --admin-enabled true
This step is only recommended for this tutorial.
Then we look for the server and credentials:
az acr show --name alberto --query loginServer
az acr credential show --name alberto
Create an Azure Container Instance
Run the following command to create an Azure Container Instance
After some minutes the server will become available for our pipelines:
Exercise - Create a build agent that runs on Azure - Learn
In this unit, to configure a build agent that you can use in Microsoft Azure Pipelines, you use a virtual machine that…
Deploy a Docker image to an Azure Container Instance - Learn
Describe the purpose of an Azure Container Instance and the Azure Container Registry. Describe how to add an image to…
Run a self-hosted agent in Docker - Azure Pipelines
This article provides instructions for running your Azure Pipelines agent in Docker. You can set up a self-hosted agent…
We connected a container build agent hosted in Azure Container Instance to Azure DevOps.
Using containers as build agents offer flexibility and reduces the costs of maintaining and updating virtual machines.