Agent Pool and Self-hosted Agent

What is an agent?

Agent in Azure DevOps is a computing infrastructure that can be used to build code or deploy applications on it using Azure Pipeline. The agent has agent software installed that runs one job at a time. It’s a similar concept as a slave node in Jenkins.

What is Agent Pool?

Agent pool is a collection of agents. Agents can be managed and organized easily in the Agent pool instead of managing individually. Agent pools are configured at the organization level, so that agent machines can be shared among all the projects.

So, let’s see how to configure the Agent in Agent pool. This demo will show you how to configure Agent in Windows server.

Step1: Creating Agent Pool

✔ Go to Organization settings

organization-setting

✔ Scroll down in left and go to Agent Pool and click Add Pool and choose Self-hosted.

add-pool

✔ Give a name to pool and click on create.

✔ New Agent pool will be listed on the screen

Step 2. Download the agent file.

✔ Go inside the new Agent pool created in above step.

✔ Click “New Agent” button to create.

✔ Next screen will allow you to download agent for the server.

new-agent

✔ Download the agent.

Step 3. Create a Personal Access Token (PAT) for the agent

✔ Click on the upper right corner and then click on Personal access tokens.

pat-option

✔ Next, click on the New token and fill the details for the token and create the token.

✔ You can customize the scope of access by checking the custom defined under Scope.

pat-config

✔ Copy and save the token for future use.

Step 4. Configure the agent on the server.

✔ Extract the downloaded file.

✔ Open PowerShell as Administrator and go into the extracted file.

cd-to-file

✔ Now, run the config.cmd file.

run-cmd

✔ Provide following data:

Enter server URL: Enter the Azure DevOps URL here.

azure-devops-url

Enter personal access token: paste the token created in Step 3.

Enter agent pool: enter the exactly same name used while creating agent pool in Azure DevOps.

Enter agent name: give a name to the agent using name convention (a meaningful name). for eg. Build-agent

Enter run agent as service? (Y/N): write Y and press Enter.

✔ After pressing some Enter, the agent will be installed on server.

agent-config

Step 5. Now check agent in Agent Pool

Go into the agent pool created in Azure DevOps and click on the Agents tab at the top to see the agent just created.

offline-agent

Currently the agent is offline and cannot be used in Azure Pipeline.

Step 6. Make agent online.

To make the agent we need to start the agent on the server as server.

✔ Open Run app by pressing Windows + R and write “services.msc” and click on OK.

✔ This will open the Service app of Windows.

✔ Look for Azure Pipeline Agent service and open its properties by right clicking on it.

✔ Change Startup type to “Automatic” from drop-down.

✔ Next, in the Log On in properties, check Local System account like shown in image below.

log-as

✔ Next, click on Apply and then OK button.

✔ Now, start the Azure Pipeline Agent service.

✔ This will make the agent online and ready for Azure Pipeline.

online-agent

Conclusion:

Here we have learned about Agent, Agent Pool, and self-hosted Agent in Azure DevOps. We have learned how can we create a self-hosted agent on a Windows system/server.

In the next module, we will learn how we can use the agent’s resources to run Azure Pipeline.