In this hands-on lab, you will be installing the build agent on a self-hosted Windows server, and then using that self-hosted build agent inside of a build pipeline. This process is an alternative to using Microsoft-hosted build agents and allows you to customize your build agent to your specific needs.
Successfully complete this lab by achieving the following learning objectives:
- Create a New Azure DevOps Organization
- Login to the Azure portal, click on All services and select Azure DevOps.
- Click on the My Azure DevOps Organizations link (this will open a new tab).
- Once the fields have auto-populated with the name, email, and location, click Continue.
- Under Get started with Azure DevOps, click the Create new organization button.
- If prompted to agree to the terms of service, click the Continue button.
- Choose a name for your new DevOps Organization (the default will suffice).
- Choose the location Central US for the region to host your projects in and click Continue.
- On the project creation screen, type in "Application" for the project name.
- Set the visibility to Public.
- Click Create project.
- Log in to the Windows Server and Install the Agent
- Go to the Azure Portal and click Virtual Machines.
- Select the VM and click Connect.
- Download the RDP file and log in to the server with the credentials
- Open Internet Explorer and go to https://aex.dev.azure.com.
- Select your organization name, followed by the project name.
- Go to Project settings > Agent pools > Default.
- Select New agent, click on the Download button, and click Save.
- Once the file has been downloaded, from PowerShell run the command:
mkdir agent ; cd agent
- From PowerShell, run the following command, replacing
<FILE_NAME>with the name of the
vstsfile you downloaded (e.g.,
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$HOMEDownloads<FILE_NAME>", "$PWD")
- Type in the server URL (https://dev.azure.com/[your-organization-name]).
- Press Enter to accept PAT as the authentication type.
- Create a PAT from the DevOps Organization by clicking on the avatar in the upper right and selecting Personal access tokens.
- Name the token "agent", select Full access, and click Create.
- Copy the token and paste it into PowerShell.
- Press Enter to accept the defaults for
agent name, and
Yto run the agent as a service and enter the server credentials
- Import the Code Repository into Azure Repos
- From the DevOps Project, go to Azure Repos and select Import.
- Enter the following repository: https://github.com/chadmcrowell/devops-asp-build
- Click Import.
- Create and Run the Build Pipeline
- From the DevOps Project, click on Azure Pipelines.
- Click New Pipeline.
- Select Azure Repos Git.
- Select the Application repository.
- Select the ASP.NET pipeline template.
- Change the YAML under
pool: name: Default
- Click on Save and run.
- Click on Save and run again.
- View the logs to see the correct build agent being used and wait for the build to complete.
- Click on Project settings > Agent pools > Default > Agents to see the job attached to the agent.