This example deploys a full environment to support azure devops agents. For each new pipeline, one agent container will be instanciated, and then removed once the pipeline ends.
Note: If there is no agent in the pool, the pipeline will fail. To workaround this limitation, a "placeholder" agent must be configured in order to always have 1 agent in the pool. This agent will be a "fake" agent as it will always be marked as offline.
- Create an agent pool and save its name and id.
Note: the pool ID corresponds to thequeueId
from the url when a pool is selected in the browser.
Example:https://dev.azure.com/myOrg/myProject/_settings/agentqueues?queueId=11&view=jobs
, the pool ID is 11 - Create a PAT (Personal Access Token) with the following permissions:
Agent Pools
:Read & manage
to be able to register / unregister agentsBuild
:Read
for Keda to be able to get the queue of pending builds
- Configure the max number of parallel jobs in Azure Devops so that your ACA does scale accordingly
This repositories has 3 implementations to create self-hosted runners:
- based on Azure Container Apps:
- arm
- terraform
- based on Azure Kubernetes Services with Keda
There are 2 possibilities to deploy a placeholder agent:
-
using the provided terraform code, the following commands will, create a VM, register it as a devops agent and finally remove it (leaving the agent in the azure devops pool):
cd placeholder-agent az login terraform init terraform apply -auto-approve # Wait for the agent to appear in the pool before running destroy terraform destroy -auto-approve cd -
-
From an azure devops agent pool, click on "New Agent" and follow the instructions. You will need a temporary VM to install the agent. The VM might be deleted once the agent has been registered in the pool.