Azure DevOps Self Hosted Build Agents

4 MIN READ

Agent is a server with the appropriate Operating System and the tools installed and configured.
Azure DevOps Supports below two agents :

Microsoft agents – These Agents are totally manages by azure

Self-Hosted Agents – These agents are configured by the user according to their needs.

Azure DevOps Self Hosted Build Agents

Steps To configure Self-Hosted Agents

In this Section, We will see how to configure a self-hosted agent for Windows And Linux VM

Creating a Personal Access Token (PAT)

Before We start configuring agents we need to create a PAT token.

Step 1. Go to and log in to the Azure DevOps organization’s user settings, and then select “Personal access tokens.”

log in to the Azure DevOps organization’s user settings, and then select “Personal access tokens

Step 2. In the Personal Access Token Page, click on the new token to Create the new token

In the Personal Access Token Page, click on the new token to Create the new token

Step 3. Provide the details Name of the token Expiration Date and permissions to this token

Provide the details Name of the token Expiration Date and permissions to this token

Note: Make sure to give full access for pipelines

Make sure to give full access for pipelines

Step 4. Once the token is generated, save it and use it in configuring agents.

Once the token is generated, save it and use it in configuring agents.

Installing & configuring the agents

We have created the token so now we can start configuring the self hosted agents

Below are the steps to create a self hosted agents

Step 1. Navigate to the organization setting and then click on Agents pools.

Navigate to the organization setting and then click on Agents pools

Step 2. Select the Default Pool or You can create your own pool By clicking Add Pool

Select the Default Pool or You can create your own pool By clicking Add Pool

Step 3. Now Click on new agent and follow the steps mentioned in that

Now Click on new agent and follow the steps mentioned in that

Step 4. You can select the desired operating system also

You can select the desired operating system also

Windows Installation

Step 1. First Download the agent it will create a zip file

Step 2. Now extract the zip file to the target location( it is recommended to save in C: drive)

# Create directory and navigate to the directory

New-Item -Path “C:” -Name “agents” -ItemType “directory”

Set-Location -Path “C:agents”

# Extract the downloaded zip file

Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory(“C:vsts-agent-win-x64-2.195.1.zip”, “$PWD”)

# Verify the extraction

Get-ChildItem

extract the zip file to the target location

Step 3. Start configuring the agent by below command

.config.cmd

Start configuring the agent by below command

It will ask you some question which are mentioned below

  • Enter the URL: https://dev.azure.com/{your-organization}
  • Enter the authentication type (press enter for PAT) – Press enter for this step.
  • Enter personal access token. – Paste the PAT generated earlier
  • Enter Agent Pool – Press Enter if you are creating an agent in the default Agent pool, otherwise, provide the name of the Agent Pool
  • Enter Agent Name – Provide the Agent Name
  • Enter run agent as Service – Press Y for this in order to install & Run the Agent as a service in the Virtual Machine.

Step 4. Now Go back to the agent pool and now you can see the agent under the pool

Now Go back to the agent pool and now you can see the agent under the pool

Linux Installation

Installing and configuring the pipeline agent in Linux is similar to Windows. So, here we can see how to install Linux Agent

Step 1. Download the agent

Download the agent

wget https://vstsagentpackage.azureedge.net/agent/2.195.1/vsts-agent-linux-x64-2.195.1.tar.gz

Step 2. Create a folder and extract the downloaded tar.gz file.

# Create directory and navigate to the directory

mkdir agent

cd agent

# Extract the downloaded zip file

tar zxf ~/Downloads/vsts-agent-linux-x64-2.195.1.tar.gz

# Verify the extraction

ls

Step 3. Start configuring the giving below command

./config.sh

Start configuring the giving below command

Similar to Windows configuration, the users will be asked to enter the server details, authentication type, and the authentication token we created earlier. Then configure the agent details, and finally, the user can start the agent by running the run.sh script.

Step 4 (Optional). You can configure the agent to run as a system service using the svc.sh script located in the agent directory. Specify the user and use the install command to configure the service.

sudo ./svc.sh install [user name]

sudo ./svc.sh start

Step 5. Now go back to the agent Pool and under this pool you will get the agent running

Now go back to the agent Pool and under this pool you will get the agent running

I hope you’ve understood configuring a self-hosted agent for Windows and Linux VM. If you like this post, remember to share this post with others to support us in reaching more needy people.

If you still face any issues executing these steps, consider contacting our microsoft azure managed services professionals. We have over eight years of experience and can efficiently fix complex problems.