Azure DevOps Self Hosted Agent Installation and Management

Author

Reads 603

Experience a serene ocean view with an expansive blue sky and distant islands on the horizon.
Credit: pexels.com, Experience a serene ocean view with an expansive blue sky and distant islands on the horizon.

Installing Azure DevOps Self-Hosted Agents is a straightforward process that can be completed in just a few steps. You can install the agent on a Windows or Linux machine, and it requires administrative privileges to run.

To get started, you'll need to download the Azure DevOps Self-Hosted Agent from the Azure DevOps website. This can be done by navigating to the Azure DevOps website and clicking on the "New pipeline" button.

The agent installation process involves running a single command in the terminal, which will download and install the necessary components. The command is: `./configure.sh`.

Once the installation is complete, you can verify that the agent is working by running the command `az devops configure` and following the prompts.

Azure DevOps Self-Hosted Agent

You can use self-hosted agents in Azure Pipelines or Azure DevOps Server, formerly named Team Foundation Server (TFS).

Self-hosted agents give you more control to install dependent software needed for your builds and deployments. They also allow machine-level caches and configuration to persist from run to run, which can boost speed.

Credit: youtube.com, Deploy & Configure Azure DevOps Self-Hosted Agent | Private Agent Pool | Azure DevOps | YAML | Ep-5

Installing multiple agents on a single machine is not recommended, as it might adversely affect performance and pipeline results.

Before installing a self-hosted agent, consider whether a Microsoft-hosted agent pool will work for you.

You can install self-hosted agents on Linux, macOS, or Windows machines, as well as on a Docker container.

To install an agent on macOS, you need to clear the special attribute on the download archive to prevent Gatekeeper protection from displaying for each assembly in the tar file when ./config.sh is run.

Here are the installation options for self-hosted agents:

  • macOS agent
  • Linux agent
  • Windows agent
  • Docker agent

Agents are widely backward compatible, but only the most recent version of the agent is supported, as it's the only version guaranteed to have all up-to-date patches and bug fixes.

Installation and Configuration

To install and configure an Azure DevOps self-hosted agent, you'll need to create a personal access token in the Azure DevOps portal. This token will be used to authenticate the agent.

Credit: youtube.com, Azure DevOps | Setting up self-hosted Build Agent

You can create a personal access token by navigating to the user settings icon, clicking on Personal access tokens, and then clicking on New Token. Select Agent Pools (read, manage) for the scope and ensure all the other boxes are unchecked.

The token is created, copy and store it for future use. The on-premise Azure DevOps agent will use this token to communicate with Azure DevOps organization.

You can download the agent as a zip file from the Azure DevOps portal, and extract it to a folder named agents in the root of the C drive (C:agents).

You can start the agent configuration by running the following command in an Elevated Powershell prompt. You will be required to enter configuration details such as server URL, authentication type, agent details, and whether to configure the agent as a Windows service.

Installing and Configuring

To install the Azure DevOps self-hosted agent, you'll need to create a folder and extract the downloaded zip file to the desired destination.

Two business professionals brainstorming and planning software development with a whiteboard in an office.
Credit: pexels.com, Two business professionals brainstorming and planning software development with a whiteboard in an office.

The recommended destination is a folder named agents in the root of the C drive (C:agents). Once extracted, start the agent configuration by running the following command in an Elevated PowerShell prompt.

You'll be asked to enter configuration details such as server URL, authentication type, and agent details, including agent pool and agent name. Finally, specify whether to configure the agent as a Windows service.

You can verify that the configured Azure Pipelines Agent is running by navigating to the Services section on Windows (services.msc). To configure the agent to run as a system service, use the svc.sh script located in the agent directory.

Here are the steps to follow:

1. Download the agent as a zip file.

2. Extract the downloaded agent to the desired destination.

3. Start the agent configuration by running the following command in an Elevated PowerShell prompt.

4. Enter configuration details such as server URL, authentication type, and agent details.

5. Specify whether to configure the agent as a Windows service.

6. Verify that the configured Azure Pipelines Agent is running.

Note: The steps may vary depending on the operating system and environment you are using.

VM Image

Credit: youtube.com, How to download install and run Windows 10 on VMWare (2021)

For a scale set to provision new VMs, you'll need to specify an image. Microsoft has open-sourced the scripts they use to provision build agents on GitHub.

You can use a standard Windows Server 2019 or Ubuntu 20.04 image from the store, but I wanted my build agents to be as close to Microsoft-hosted agents as possible. To do this, I used Packer by HashiCorp to automatically build my machine images.

Packer runs through a set of instructions, executes them in order, and in the end, you have a fully configured Virtual Machine. Here's a step-by-step breakdown of the process:

  • Provision a VM in Azure where Packer will be executed
  • Provision a VM in Azure where Packer will install all the prerequisites
  • Sysprep the VM at the end of the process
  • Keep the disk (as a .vhd) file
  • Destroy both the orchestrator VM as well as the full provisioned VM

After running Packer, you'll have a fully configured .vhd file that you can turn into an Azure Managed Image.

Agent Options and Settings

You have several options when it comes to setting up an Azure DevOps self-hosted agent. One option is to create a self-hosted agent, which can be linked to the free tier and used for an unlimited number of minutes.

Credit: youtube.com, Configure Self Hosted Agent - Azure DevOps

Another option is to consider using Docker or a VM, but this might add complexity to getting it up and running quickly. A simpler alternative is to test it out on WSL, which allows you to run Linux distros on your Windows device.

You can install multiple Linux distros on WSL2, including Ubuntu-18.04, and use it for your self-hosted agent. This can be a convenient option if you don't want to change your pipeline dependencies.

Options

If you're looking for options to host a self-hosted agent, you've got a few choices. One option is to use a self-hosted agent, which is a great solution since the free tier allows you to link one self-hosted agent for an unlimited number of minutes.

You can run a self-hosted agent on Linux, which is a requirement for one of the pipeline dependencies mentioned in the article. This means you can't run it on your Macbook or Windows machines.

Credit: youtube.com, Theme options agents Settings

You might be thinking about using Docker or a VM, but these options would make it more complex to get up and running quickly.

Here are some alternatives to consider:

  • Docker/Container
  • VM

The author of the article actually tested WSL (Windows Subsystem for Linux) as an alternative, which turned out to be a great option. They used WSL2 with Ubuntu-18.04 on their Windows device.

Communication with Server

To communicate with servers, you need to ensure the agent has "line of sight" connectivity to those servers. This means the agent can directly access the servers without any firewalls or other obstacles in the way.

Microsoft-hosted agent pools have connectivity to Azure websites and servers running in Azure by default. This is a convenient option, but it may not work for all environments.

If your Azure resources are running in an Azure Virtual Network, you can get the Agent IP ranges to configure firewall rules for your Azure VNet. This allows the agent to access your Azure resources.

Credit: youtube.com, Server to Agent Communications Overview

On the other hand, if you're working with on-premises environments, you'll need to manually configure self-hosted agents on on-premises computers. This is because intermediate firewalls often block access to Microsoft-hosted agent pools.

Self-hosted agents must have connectivity to the target on-premises environments, as well as access to the internet to connect to Azure Pipelines or Team Foundation Server.

Parallel Jobs

Parallel jobs allow you to run multiple jobs simultaneously in your organization. You can run a single job at a time with one parallel job, but need two to run two jobs at the same time.

Microsoft provides a free tier of service that includes at least one parallel job by default. This means you don't have to pay for self-hosted concurrent jobs in releases, but you're limited by the number of agents you have.

To use multiple agents at the same time, you might need more parallel jobs. You can run parallel jobs on Microsoft-hosted infrastructure or on your own self-hosted infrastructure.

If you install new software on a self-hosted agent, you must restart the agent for the new capability to show up. This is a simple step to ensure your agent is up-to-date and running smoothly.

Agent Management and Maintenance

Credit: youtube.com, Maintenance Jobs for build agents explained - Azure DevOps

To manage your Azure DevOps self-hosted agents effectively, it's essential to have a plan in place for agent management and maintenance.

You can add, remove, or update self-hosted agents in Azure DevOps, and you can also configure agent pools to control which agents are used for specific tasks.

Self-hosted agents are typically installed on a Windows or Linux machine, and you can have multiple agents on the same machine if needed.

To keep your agents up to date, Azure DevOps will automatically update the agent software when a new version is available, as long as the agent is connected to the internet.

You can also configure your agents to run tasks in parallel, which can improve the overall efficiency of your build and deployment process.

It's a good idea to regularly review the agent logs to ensure that your agents are running smoothly and to troubleshoot any issues that may arise.

By following these best practices for agent management and maintenance, you can ensure that your Azure DevOps self-hosted agents are running efficiently and effectively.

Frequently Asked Questions

How many types of agents are there in Azure DevOps?

There are two types of build agents in Azure DevOps: Microsoft-hosted and self-hosted. Learn more about the differences between these agent types and how to set them up for your Azure Pipelines.

Can you self host Azure?

Yes, you can self-host Azure by using the Create self-host IR template, which sets up a fully functional self-hosted IR inside an Azure virtual network. This template automates the setup process for a seamless experience.

Tiffany Kozey

Junior Writer

Tiffany Kozey is a versatile writer with a passion for exploring the intersection of technology and everyday life. With a keen eye for detail and a knack for simplifying complex concepts, she has established herself as a go-to expert on topics like Microsoft Cloud Syncing. Her articles have been widely read and appreciated for their clarity, insight, and practical advice.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.