Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Azure icon
Labs

Building Apps Using Self-Hosted Build Agents in Azure Pipelines

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.

Azure icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Published
Clock icon Nov 08, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create a New Azure DevOps Organization

    1. In the search bar at the top of the page, type devops and select Azure Devops organizations.
    2. Click My Azure DevOps Organizations.
    3. Once the fields have auto-populated, click Continue.
    4. Click Create new organization.
    5. If prompted to agree to the terms of service, click Continue.
    6. Leave the default region and organization name, complete the CAPTCHA at the bottom, and click Continue.
    7. On the Create a project to get started page under Visibility, click the organization policies link.
    8. Under Policies, scroll down to Security policies and toggle on Allow public projects.
    9. In the Change policy setting window, click Save.
    10. Navigate back to the project page.
    11. Under Project name, type application.
    12. Under Visibility, select Public and click + Create project.
  2. Challenge

    Log In to the Windows Server and Install the Agent

    1. Return to the main Azure portal page and navigate to Virtual machines.

    2. Select the provisioned virtual machine.

    3. In Overview, click Connect > RDP.

    4. Click Download RDP File.

    5. Download the RDP file and log in to the server using the VM credentials provided on the lab page.

    6. Navigate to https://aex.dev.azure.com.

      Note: In the Azure VM, we strongly recommend downloading, installing, and using Google Chrome instead of the default Internet Explorer browser.

    7. Sign in using the Azure portal credentials provided on the lab page.

    8. Select your organization name.

    9. Select the application project.

    10. At the bottom of the left menu, select Project settings.

    11. Under Pipelines select Agent pools and click Default.

    12. At the top right, click New agent.

    13. Under Download the agent, click Download

    14. From the Windows Start menu search bar, type powershell.

    15. Right-click on Windows PowerShell ISE and click Run as administrator.

    16. In PowerShell, create and navigate into the agent directory:

      mkdir agent ; cd agent
      
    17. Create the agent, replacing <FILE_NAME> with the name of the vsts file you downloaded (e.g., vsts-agent-win-x64-2.175.2.zip):

      Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$HOME\Downloads\<FILE_NAME>", "$PWD")
      
    18. To configure the agent, run the .\config.cmd file:

      .\config.cmd
      
    19. Type in the server URL, replacing <YOUR_ORGANIZATION_NAME> with your own, which you can get from the browser bar (copy everything before /application):

      https://dev.azure.com/<YOUR_ORGANIZATION_NAME>
      
    20. Press Enter to accept a personal access token (PAT) as the authentication type.

    21. To create a PAT from the DevOps organization, click on the human avatar in the upper right of the portal (Cloud Student ...) and select Security > Personal access tokens.

    22. Click + New Token.

    23. In Name, type agent.

    24. Under Scopes, select Full access and click Create.

    25. Copy the agent token and paste it into PowerShell.

    26. To accept the defaults for agent pool, agent name, and work folder, press Enter.

    27. To run the agent as a service, enter Y and enter the VM credentials provided on the lab page.

    28. To verify configuration, return to the DevOps organization page and navigate to application > Settings > Agent pools Default.

    29. Select the Agents tab and view the agent pool status.

      You should see a green status icon indicating the pool is online.

  3. Challenge

    Import the Code Repository into Azure Repos

    1. On the left menu, select Repos.
    2. Scroll down to Import a repository and click Import.
    3. Under Clone URL, paste in the following repository link: https://github.com/chadmcrowell/devops-asp-build
    4. Click Import.
  4. Challenge

    Create and Run the Build Pipeline

    1. On the left menu, click Pipelines.

    2. Click Create Pipeline.

    3. Select Azure Repos Git.

    4. Select the application repository.

    5. Select the ASP.NET pipeline template.

    6. In the YAML under pool, delete the vmImage line and replace it with the following:

      pool:
        name: Default
      
    7. Click Save and run > Save and run.

      A status window will appear stating the pipeline needs permissions to access a resource before this run can continue.

    8. In the status window, click View > Permit > Permit.

    9. To verify our job ran on the selected agent once the build has run, click Project settings > Agent pools > Default > Agents.

    10. Click the listed agent to see the job attached to the agent.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans