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:
An Azure DevOps organization (e.g., https://dev.azure.com/your-org-name)
A Go4hosting Cloud VPS, dedicated server, or another machine that:
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
Go to your Azure DevOps organization: https://dev.azure.com/your-org-name.
Navigate to Project Settings - Agent pools.
Click Add pool.
Provide a name for the pool (e.g., "Go4hosting-Linux-Agents").
Choose whether to make it available to all projects or just specific ones.
Click Create.
Your agent pool is now ready.
Step 2: Download the Agent Package
Go to Agent pools - Select your pool - Click New agent.
Select the operating system of your agent machine (Windows, Linux, or macOS).
Download the agent package.
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
Install required packages:
bash
CopyEdit
sudo apt update
sudo apt install -y libssl-dev libkrb5-dev
Create a directory for the agent:
bash
CopyEdit
mkdir myagent && cd myagent
Extract the agent package:
bash
CopyEdit
tar zxvf ~/path-to-agent-package.tar.gz
For Windows Agents
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)
Go to User Settings - Personal Access Tokens in Azure DevOps.
Create a new token with Agent Pools (Read & manage) scope.
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
Go back to Agent pools in Azure DevOps.
Select your pool and verify that your agent appears as Online.
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
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:
Fast provisioning:
Network isolation:
24/7 support:
Troubleshooting Common Issues
Agent Not Showing Online
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
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.