Azure Pipelines Agents

Azure Pipelines Agents

Introduction:

To build and deploy your code using Azure Pipelines, you need at least one agent. When your pipeline runs, the system begins one or more jobs. An agent is computing infrastructure with installed agent software that runs one job at a time.

Azure Pipelines provides several different types of agents:

1. Microsoft Hosted Agents

If your pipelines are in Azure Pipelines, then you've got a convenient option to run your jobs using a Microsoft Hosted agent. With Microsoft-hosted agents, maintenance and upgrades are taken care of for you. You always get the latest version of the VM image you specify in your pipeline. Each time you run a pipeline, you get a fresh virtual machine for each job in the pipeline. The virtual machine is discarded after one job (which means any change that a job makes to the virtual machine file system, such as checking out code, will be unavailable to the next job). Microsoft-hosted agents can run jobs directly on the VM or in a container.

Azure Pipelines provides a predefined agent pool named Azure Pipelines with Microsoft-hosted agents.

For many teams this is the simplest way to run your jobs. You can try it first and see if it works for your build or deployment. If not, you can use Self Hosted agent or Azure Virtual Machine Scale Set agents.

2. Self Hosted Agents

This is a service that you need to set up and manage by yourself. This can be a custom virtual machine on Azure or a custom on-premise machine inside your infrastructure. In a self-hosted agent, you can install all the software you need for your builds, and this is persisted on every pipeline execution.

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

You can install the agent on Linux, macOS, or Windows machines. You can also install an agent on a Docker container.

Ways to Setup Self Hosted Agents:

  • Azure Virtual Machine

  • Azure Virtual Machine Scale Sets (VMSS)

  • Containers etc.

3. Azure Virtual Machine Scale Set Agents (VMSS)

Azure Virtual Machine Scale Set agents are a form of self-hosted agents that can be auto-scaled to meet your demands. This elasticity reduces your need to run dedicated agents all the time. Unlike Microsoft-hosted agents, you have flexibility over the size and the image of machines on which agents run.

You specify a Virtual Machine Scale Set, a number of agents to keep on standby, a maximum number of virtual machines in the scale set, and Azure Pipelines manages the scaling of your agents for you.

This is similar to AWS AutoScaling Groups or GCP Managed Instance Groups.

Conclusion

Azure Pipelines is a powerful tool for automating the build and deployment processes of your code. Central to its functionality are agents, which serve as the computing infrastructure responsible for executing the tasks defined in your pipeline. Whether you opt for Microsoft-hosted agents for convenience, self-hosted agents for flexibility and control, or Azure Virtual Machine Scale Sets agents for dynamic scaling, Azure Pipelines offers a range of options to suit your specific needs. By leveraging these agents, you can streamline your development workflow, improve efficiency, and ensure reliable delivery of your software applications.