Azure DevOps Self Hosted Agent

zure devops self hosted agent creation

Microsoft Azure DevOps is a cloud service that provides full-scale DevOps capabilities to manage infrastructure in the Azure cloud. It supports the deployment of the builds from release pipelines to the on-premise or private cloud environments using self-hosted pipeline agents. This article describes creating an Azure DevOps self-hosted agent on a Windows server.

Pre-requisites
1. Azure DevOps account with owner permissions on the organization.
2. Windows machines with OS versions supported are 7, 8.1, 10, and Windows 2008 R2 SP1 or higher. And .Net Framework 4.6.2 or higher.

Process

Microsoft made creating Azure DevOps self-hosted agents easy in an on-premise environment. This section describes how to do it.

Create an Agent pool and download the agent.

Follow the below steps to create an agent pool in Azure DevOps and download the agent.

  1. Open Azure DevOps portal and navigate to the organization where you want to add the agent.
  2. Click on Organization settings.
  3. Click on Agent pools under the pipelines.
  4. Click on Add pool.
  5. Select Pool type as Self-hosted and provide a suitable name (say OnPremAgentPool). And click Create.
  6. Click on the newly created Agent pool (OnPremAgentPool) and the New agent button.
  7. Click the Download button to download the agent pool zip file under the Windows tab. This is the server where you want to create an on-premise Agent pool.
azure devops self hosted agent

Configure Azure DevOps agent

Once you have downloaded the zip file, follow the below instruction to configure the Azure DevOps agent in an on-premise machine.

  1. Navigate to the organization in the DevOps portal and click on the user settings icon at the top-right corner of the page. Click on Personal access tokens from the drop-down menu. Click on New Token. Select Agent Pools (read, manage) for the scope and ensure all the other boxes are unchecked. Once the token is created, copy and store the token for future use.
    The on-premise Azure DevOps agent will use this token to communicate with Azure DevOps organization.
  2. Open PowerShell ISE on the Windows machine and execute the below command.
cd C:\ #base location for the agent folder. You can set it as per your needs.
mkdir agent
cd agent
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$HOMEDownloadsvsts-agent-win-x64-2.187.2.zip", "$PWD")

3. Navigate to the folder path C:\agent.
4. Double-click on config.cmd file. This will open a cmd prompt with the below questionnaire.

Enter server URL > https://dev.azure.com/<organisation name>/
Enter authentication type (press enter for PAT) > <Press enter>
Enter personal access token > <Enter access token generated in step 1> If the connection is successful, it will ask you to register an agent.
Enter agent pool (press enter for default)> <Name of the agent pool created earlier (OnPremAgentPool)>
Enter agent name (press enter for <servername>) > <Provide any suitable name for the agent. The default is Server name>
It will connect and test the agent connection. If it is successful,
Enter work folder (press enter for _work) > <press enter>
Enter run agent as service? (Y/N) (press enter for N) > (Enter Y if you want to run this as a service)
Enter configure autologon and run agent on startup? (Y/N) (press enter for N) > (Enter Y if you want to start the service on startup)

How to setup azure devops self hosted agent

Congratulations, you have set up the agent!

Start and Verify the Azure DevOps self hosted agent.

1. Navigate to the folder path C:\agent.
2. Double-click on the run.cmd file. This will open a cmd prompt and connect to the server. After the successful connection, it will start listening for jobs.
3. You can return to the Agent pools in Azure DevOps organization and see your agent status online.

Azure DevOps self-hosted agent is now ready to use in Release pipelines for on-premise deployments.

See more

Pro tips:
1. Learn how to automate Azure Data Factory deployments using Azure DevOps.

Kunal Rathi

With over a decade of experience in data engineering and analytics, I've assisted countless clients in gaining valuable insights from their data. As a dedicated supporter of Data, Cloud and DevOps, I'm excited to connect with individuals who share my passion for this field. If my work resonates with you, we can talk and collaborate.
I am always interested in new challenges so if you need consulting help, reach me at kunalrathi55@gmail.com.

Shopping Cart
Scroll to Top