Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Latest commit

 

History

History

301-deploy-agent-vms

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Deploy hosted agent VMs

About this template

This template shows how to use Terraform to deploy a pool of agent VMs on which a subsequent job is run.

Watch the video

The Terraform definition does not contain any other resources. You can extend the definition with your custom infrastructure, such as Web Apps.

Agent deployment scripts

The template deploys agents at a high density, with (by default) 2 agent VMs with 4 Azure DevOps build agents per VM. This is efficient when running pipelines that do not require much local computing power, or only sporadically.

Walkthrough

Creating an agent pool

In your Azure DevOps project settings, create an Agent pool. Name the pool starterpool (if you want to use a different name, change the value in azure-pipelines.yml).

Creating a PAT token

In Azure DevOps, create a PAT token. Click on Show all scopes and grant the token Read and Manage permissions on Agent Pools.

PAT token

Under Library, create a Variable Group named terraform-secrets. Create a secret named AGENT_POOL_MANAGE_PAT_TOKEN and paste the token value. Make the variable secret using the padlock icon.

Using the template

To use the template, follow the section How to use the templates in the main README file.

Automatic shutdown of agents

The pipeline configures the agent VMs to automatically shutdown daily at 23:00 UTC. To use a different schedule, change TF_VAR_az_devops_agent_vm_shutdown_time in azure-pipelines.yml, or remove that line completely to disable automatic shutdown.

The pipeline contains a task to start up the agent VMs again before running the agent job.