Skip to main content

HOWTO Create a self-hosted Azure DevOps agent

Requirements

You need to be administrator of the virtual machine (VM) that will be used to be the Azure DevOps agent.

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 OS

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 OS

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:\Agent folder and give all permissions to user Network service (used by Azure DevOps agent)
    • Download chromedriver.exe from chromedriver.storage.googleapis.com and extract it inside C:\Agent
      • Create a system environment variable ChromeWebDriver whose value is C:\Agent\chromedriver_win32
    • Download psexec and extract it to C:\Agent
    • Follow instuctions
      • Use Ubuntu 18.04
      • Rename to zip file, extract and move to C:\Agent
    • Open a command window, go to C:\Agent\PSTools and execute psexec -i -u "nt authority\network service" cmd.exe

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

Additional resources