Azure Pipelines self-hosted agent installation

A simple set of instructions for installing self-hosted agents for Azure DevOps. This helps when needing to create many agents at once.

References

Steps

  1. Install Windows updates. May require restart.

  2. Install Chocolately

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  1. Install agent dependencies
choco install visualstudio2022buildtools -y
  1. Download agent
mkdir C:\Installs
Invoke-WebRequest -Uri "https://vstsagentpackage.azureedge.net/agent/3.220.2/vsts-agent-win-x64-3.220.2.zip" -OutFile "C:\Installs\vsts-agent-win-x64-3.220.2.zip"
  1. Create directory for new agent. The naming structure for the agent name and folder is {{computer name}}-agent{{number}}
mkdir C:\build01-agent01
cd C:\build01-agent01
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\Installs\vsts-agent-win-x64-3.220.2.zip", "$PWD")
  1. Configure the agent
.\config.cmd --unattended --url https://dev.azure.com/[organizaiton] --auth PAT --token [token] --pool "Self-hosted" --agent build01-agent01 --runAsService --windowsLogonAccount "NT AUTHORITY\NETWORK SERVICE"

Related posts