One of the features that Azure DevOps has is to run build and release pipelines to deploy code, which is known as continuous integration and continuous deployment (CICD). To run a build or release pipeline, a container is used in Azure DevOps to run the tasks in the pipeline. The containers are known as build agents and they vary in use case depending on the type of application being deployed. The build agents that are provided by Microsoft can use Windows, OS X, or Linux, which are run in Docker containers.

Another way of using build agents is to create one, also known as self-hosted agents. Self-hosted agents are build and release pipeline agents that are being hosted on a computer. In this blog post, you will set up a build agent on Windows 10.
Prerequisites
- An intermediate to advanced level knowledge of Azure DevOps. To learn more about Azure DevOps, I recommend reading the getting started guides here.
- A Windows 10 machine
- An Azure DevOps account which you can set up for free here.
- Global admin rights to the Azure DevOps portal.
Creating a PAT token
A Personal Access Token (PAT) is an authentication method similar to using a password. A typical reason to use a PAT token is for non-Microsoft tools integrated into Azure DevOps that don't support Azure Active Directory or a Microsoft account. Creating a self-hosted agent requires a PAT.
Open up a web browser and in the Azure DevOps portal, click user settings where the PAT settings exist.

Click Personal access tokens to access the PAT settings.

Click New token to start the process of creating a new PAT.

In the Create a new personal access token settings, click Show all scopes as shown in the screenshot below to show the settings that the self-hosted build agent requires.

Select Read and manage under Agent Pools. Agent Pools is the settings that a self-hosted agent requires for access to Azure DevOps from the Windows 10 build machine.

Give the new PAT a name and click the blue Create button to create the PAT. The name on the screenshot below is Win10Agent, but this exact name is not a requirement.

Adding an Agent Pool
In the previous section you created a PAT for the Windows 10 build machine to have the ability to authenticate to Azure DevOps. The authentication is required for any build and release pipelines to use the self-hosted agent. In this section you will create the agent pool, which is where the Windows 10 build machine will be accessed in Azure DevOps and given permissions.
Open up a web browser and go to the Azure DevOps portal and click on Organization Settings shown in the screenshot below.

Under Pipelines, click Agent Pools to access the agent pool settings.

Click Add pool as shown in the screenshot below.

Give the agent pool a name and when complete, click the blue Create button. In the screenshot below you will see the name Win10Agent. This specific name is not a requirement.

The pool is now created as shown in the screenshot below.

Downloading the Self-Hosted Agent
In the previous section you created the agent pool, which is where the Windows 10 self-hosted agent will be accessed from. Even though the agent pool is created, the Windows 10 machine is not accessible through it yet. That's because the agent needs to be installed on the Windows 10 machine which you will do in this section
Log into the Windows 10 machine and from the Windows 10 machine, open up a web browser and log into the Azure DevOps portal and go to Agent pools under Organization settings.
Click on the agent pool that you created in the previous section. Within the agent pool, click on Agents where the option will be to create a new agent. An agent is what the Windows 10 build machine is called in Azure DevOps.

Click the blue New agent button to create a new agent.

Click the blue Download button to download the agent.

Configuring the Windows 10 Build Machine
In the previous section you downloaded the agent to the Windows 10 machine. The agent is an installation that creates a Windows service to communicate with Azure DevOps. In this section you will configure the agent.
In the screenshot below you will see three blocks of PowerShell code that need to be run. The PowerShell code must be run in sequential order.
Open up a PowerShell terminal as an administrator and run the first block of code highlighted in the screenshot below to create a directory called agent and to extract the the agent to the new directory.
Your agent version may look different than the one I have in the screenshots below depending on when you read this blog post. That's okay, the steps will be the same.

Run the second block of code in the PowerShell terminal that is highlighted in the screenshot below to start the configuration of the agent.

Once the .\config.cmd
is running, you will see a screenshot similar to the one below.

Open up a web browser and go to the Azure DevOps portal. Under agent pools you will see the Windows 10 build machine online. The Windows 10 build machine name you'll see will be different than the one shown in the screenshot below.

Congratulations! You have successfully deployed a Windows 10 build machine.
Summary
In this tutorial you took a hands-on approach to creating a Windows 10 build machine. The Windows 10 build machine can be used instead of a Microsoft-hosted agent that Microsoft provides depending on the use-case. You went through setting up a PAT for the Windows 10 build machine to authenticate to Azure DevOps and set up the agent pool. After setting up the agent pool you downloaded the agent on the Windows 10 build machine and configured the machine using PowerShell.
For your next challenge, take a look at configuring a self-hosted agent in a Docker container which you can find here.