Self-hosted Azure DevOps agent
Posted on by Bertrand Thomas
How-to
Automation
Workflow
Let's see how to use a virtual machine as Azure DevOps agent.
Requirements
You need to be administrator of the virtual machine (VM).
Azure VM
- Go to Azure Portal:
- Create the new VM (for example Windows 2019 Datacenter or Ubuntu 18.04)
- For Windows:
- Update networking to only allow RDP on Ops location IP
- Download RDP file
Linux systems
Installation steps on Linux
-
SSH to the machine:
# run updates sudo apt-get update # download the agent file wget https://vstsagentpackage.azureedge.net/agent/2.168.2/vsts-agent-linux-x64-2.168.2.tar.gz # uncompress the file tar zxvf ../vsts-agent-linux-x64-2.168.2.tar.gz # run the configuration ./config.sh
Windows systems
Installation steps on Windows
- Connect to the machine (RDP with
mstsc.exe):- Run Windows Updates
- Enable Windows Subsystem for Linux Feature
- Download and install Mozilla
- Download and install Chrome
- Download and install Notepad++
- Download and install git
- Download and install .NET Core
- Download and install 7-zip
- (Optional) Download and install Azure CLI
- (Optional) Download and install MongoDB CLI, and:
- Add bin directory in the PATH
- Download and install Visual Studio Build Tools
- Create
C:\Agentfolder and give all permissions to userNetwork service(used by Azure DevOps agent) - Download
chromedriver.exefrom chromedriver.storage.googleapis.com and extract it insideC:\Agent- Create a system environment variable
ChromeWebDriverwhose value isC:\Agent\chromedriver_win32
- Create a system environment variable
- Download psexec and extract it to
C:\Agent - Follow instuctions
- Use
Ubuntu 18.04 - Rename to zip file, extract and move to
C:\Agent
- Use
- Open a command window, go to
C:\Agent\PSToolsand executepsexec -i -u "nt authority\network service" cmd.exe- In the new window go to
C:\Agent\CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.XXX.YYYand executeubuntu1804.exe(see Windows Server Installation Guide and Manually download Windows Subsystem for Linux distro packages) - Execute bash
- (Optional) Install MongoDB
- In the new window go to
Configuration steps on Windows
- Go to Azure DevOps, follow the documentation
- Create a new Personal Access Token
- Add pool from
https://dev.azure.com/yourorganization/_settings/agentpools - Once create, click on New Agent
- Copy agent zip file and extract it in
C:\Agent - Download the agent file, unzip it and inside execute the command
config.cmd(chose service) - Update agent capabilities
- (Optional) Go to external systems (such as MongoDB Atlas and Azure VM networking)
- Add VM IP in system IP allowed list