How to Configure Self-Hosted Agents in Azure DevOps

Azure DevOps is a powerful platform that supports continuous integration (CI) and continuous delivery (CD) pipelines for modern software development. By default, Azure DevOps provides Microsoft-hosted agents that run builds and deployments. However, many organizations-especially those with custom environments, special hardware needs, or security requirements-prefer to use self-hosted agents.

In this knowledgebase article, Go4hosting explains how to configure self-hosted agents in Azure DevOps, why you might want to use them, and best practices for managing them on cloud servers or dedicated servers.

What Is a Self-Hosted Agent?

An agent is a software component that runs your build and deployment jobs. It:

  • Downloads pipeline tasks.

  • Executes build scripts or deployment steps.

  • Uploads results to Azure DevOps.

You can choose between:

  • Microsoft-hosted agents: Run in Microsoft-managed Azure environments. Easy but limited in customization.

  • Self-hosted agents: Run on your own cloud server, virtual machine, dedicated servers, or even on-premises hardware. Fully customizable.

Why Use Self-Hosted Agents?

Go4hosting customers often use self-hosted agents because:

  • You need special software or tools installed.

  • You require specific OS versions or custom configurations.

  • You want to use GPU-enabled or high-performance servers.

  • You have networking or security requirements that can't be met by Microsoft-hosted agents.

  • You need faster build times (no cold startup delays).

Prerequisites

Before configuring a self-hosted agent, ensure you have:

  1. An Azure DevOps organization (e.g., https://dev.azure.com/your-org-name)

  2. A Go4hosting Cloud VPS, dedicated server, or another machine that:

  3. The following software installed:

    • Git

    • .NET Core Runtime (on Linux, if required)

    • Build tools or other dependencies you need for your CI/CD pipelines.

Step-by-Step Guide: Configure a Self-Hosted Agent

Step 1: Create an Agent Pool in Azure DevOps

  1. Go to your Azure DevOps organization: https://dev.azure.com/your-org-name.

  2. Navigate to Project Settings - Agent pools.

  3. Click Add pool.

  4. Provide a name for the pool (e.g., "Go4hosting-Linux-Agents").

  5. Choose whether to make it available to all projects or just specific ones.

  6. Click Create.

Your agent pool is now ready.

Step 2: Download the Agent Package

  1. Go to Agent pools - Select your pool - Click New agent.

  2. Select the operating system of your agent machine (Windows, Linux, or macOS).

  3. Download the agent package.

  4. You'll see detailed instructions specific to your OS-follow them carefully.

Step 3: Prepare the Agent Machine

Log in to your Go4hosting Cloud VPS or server that will host the agent.

For Linux Agents

  1. Install required packages:

bash

CopyEdit

sudo apt update

sudo apt install -y libssl-dev libkrb5-dev

  1. Create a directory for the agent:

bash

CopyEdit

mkdir myagent && cd myagent

  1. Extract the agent package:

bash

CopyEdit

tar zxvf ~/path-to-agent-package.tar.gz

For Windows Agents

  • Unzip the agent package into a folder (e.g., C:\agent).

Step 4: Configure the Agent

Run the configuration script:

On Linux:

bash

CopyEdit

./config.sh

On Windows:

powershell

CopyEdit

.\config.cmd

You�ll be prompted to enter:

  • Azure DevOps server URL - https://dev.azure.com/your-org-name

  • Agent pool - Your pool name (e.g., "Go4hosting-Linux-Agents")

  • Agent name - Provide a descriptive name (e.g., "go4hosting-agent-01")

  • Authentication method - Use Personal Access Token (PAT).

Generate a Personal Access Token (PAT)

  1. Go to User Settings - Personal Access Tokens in Azure DevOps.

  2. Create a new token with Agent Pools (Read & manage) scope.

  3. Copy the token and use it during agent configuration.

Step 5: Run the Agent

On Linux:

bash

CopyEdit

./svc.sh install

./svc.sh start

On Windows:

powershell

CopyEdit

.\svc install

.\svc start

This installs the agent as a service so it runs automatically on boot.

Step 6: Verify the Agent

  1. Go back to Agent pools in Azure DevOps.

  2. Select your pool and verify that your agent appears as Online.

  3. The agent is now ready to run builds and deployments!

Using the Agent in a Pipeline

To use your self-hosted agent in a pipeline, specify the pool:

yaml

CopyEdit

pool:

  name: Go4hosting-Linux-Agents

Now your pipeline will target your self-hosted agent instead of Microsoft-hosted agents.

Best Practices for Managing Self-Hosted Agents

1. Security

  • Run agents on dedicated servers or isolated VMs.

  • Do not run agents on shared servers with unrelated services.

  • Regularly update OS and agent software.

  • Use firewall rules to restrict access.

2. Resource Management

  • Use Go4hosting Cloud VPS with scalable resources for agents:

    • Add more CPU or memory as your CI/CD load grows.

    • Scale horizontally with multiple agents.

3. Monitoring

  • Monitor agent logs (_diag folder).

  • Use Azure DevOps analytics to track agent usage.

  • Set up alerts for offline agents.

4. Agent Maintenance

  • Periodically clean build directories to free up space.

  • Install required build tools and SDKs on the agent.

  • Maintain a standard image for agents if you plan to run many.

5. Scaling Agents

  • Use agent pools to manage multiple agents.

  • Deploy multiple self-hosted agents for parallel builds.

  • Use automation (e.g., Ansible, Terraform) to deploy agents on demand in Go4hosting Cloud.

Advantages of Using Go4hosting Cloud for Self-Hosted Agents

Go4hosting provides an ideal platform for running self-hosted agents:

  • Flexible Cloud VPS:

    • Scale CPU, memory, and storage as needed.

    • Pay only for what you use.

  • Dedicated Servers:

    • Ideal for agents requiring high performance or GPU acceleration.

  • Fast provisioning:

    • Spin up Linux or Windows VMs quickly.

  • Network isolation:

    • Secure agent networks with VPCs and firewalls.

  • 24/7 support:

    • Our team can help with optimizing and securing your agent infrastructure.

Troubleshooting Common Issues

Agent Not Showing Online

  • Check firewall: Ensure the agent can reach dev.azure.com (TCP port 443).

  • Verify PAT permissions.

  • Check agent logs in the _diag folder.

Pipeline Fails on Self-Hosted Agent

  • Verify all required tools are installed (Git, build tools, SDKs).

  • Ensure agent account has proper file system permissions.

Agent Stops After Reboot

  • Ensure the agent service is set to auto-start.

  • Verify service status:

bash

CopyEdit

sudo systemctl status vsts-agent.service

Conclusion

Configuring self-hosted agents in Azure DevOps is an excellent way to:

  • Gain full control over your build environment.

  • Support specialized hardware/software needs.

  • Improve security and compliance.

  • Optimize CI/CD performance.

With Go4hosting's Cloud VPS and dedicated servers, you can easily deploy high-performance self-hosted agents tailored to your projects.

Was this answer helpful? #0 #0
 

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Related Questions

Submit your Query

  • I'm not a robot

Browse by ServicesBrowse by Services

Resource Library

What is Cloud Computing

Understand the term cloud computing, the ongoing trend, its playing field, future growth and how industry...

Myths about Cloud Computing

Cloud computing, in the recent years, has become a subject of significant discussion among the industry experts.

Download Now

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Submit Query

Please fill in the form below and we will contact you within 24 hours.