What Is Agent in DevOps?
On This Page
Quick Definition
An agent is a small program that sits on a computer and does specific jobs for you automatically. It can run tests, install updates, or collect information without you having to do it manually. In DevOps, agents are the workers that carry out tasks you set up in tools like Azure DevOps.
Commonly Confused With
A service principal is an identity used for authentication and authorization in Azure, often used by pipelines to access resources. An agent is a runtime that executes jobs. The agent may use a service principal to authenticate, but they are not the same thing, the agent does the work, while the service principal is just a security account.
The agent runs on a VM and uses a service principal to authenticate to Azure when deploying a web app.
A runner in GitHub Actions is functionally identical to an agent in Azure DevOps, both are software that executes workflow jobs. The main difference is terminology and the specific hub they connect to. GitHub has hosted runners and self-hosted runners; Azure DevOps has hosted agents and self-hosted agents. The concepts are interchangeable for most practical purposes.
A GitHub self-hosted runner is the same idea as an Azure DevOps self-hosted agent: you install it on your own machine to run jobs.
A deployment group is a logical set of target servers that receive releases, and each server in the group runs an agent. The deployment group is a collection of agents, not the agent itself. Confusing the two is like confusing a fleet of cars with a single car.
You create a deployment group called 'WebServers' and install the agent on 10 VMs. The group is the collection, the agent is the software on each VM.
Must Know for Exams
For the AZ-400 exam (Designing and Implementing Microsoft DevOps Solutions), the concept of agents is heavily tested. Specifically, the exam objectives include configuring and managing agent pools, understanding the differences between Microsoft-hosted and self-hosted agents, and troubleshooting agent-related failures. You will see questions about how to add capabilities to an agent, how to target specific agents from a pipeline using demands, and how to set up multiple agents on a single VM.
Questions often present a scenario where a build is failing because the required software (e.g., .NET Core 3.1) is not installed on the agent, and you must diagnose the missing capability.
Another common scenario is a customer who wants to run deployments in an on-premises environment with strict network restrictions, you need to recommend self-hosted agents installed behind the firewall. The exam also tests your understanding of agent pools: the difference between default, private, and Azure Pipelines agent pools; how to create and manage them; and how to grant permissions to users or service connections. You may be asked to explain how agents handle parallel jobs or why a job might be stuck waiting for an available agent.
The exam expects you to know that Microsoft-hosted agents come with popular tools pre-installed, but you cannot install custom software; self-hosted agents give you full control. Also, you should understand that agents are linked to a specific Azure DevOps organization and can be recycled or updated. Be prepared for scenario-based questions where you need to choose the appropriate agent type, configure agent capabilities, or troubleshoot connection issues.
The AZ-400 exam also touches on using deployment groups, which rely on agents to run deployment jobs across multiple servers. Understanding the agent lifecycle, install, configure, start, update, remove, is exam-relevant. In short, agents are not a minor topic; they are a core operational concept tested directly in AZ-400 and indirectly in other DevOps exams like the GitHub Actions certification.
Simple Meaning
Think of an agent like a personal assistant who lives inside your computer. You give the assistant a list of chores, and the assistant does them on schedule or when you ask. You don't need to be in the room, the assistant handles everything.
For example, you might tell your assistant to check your email every morning and sort out spam. That same idea applies to IT: an agent is a program installed on a server or laptop that waits for instructions from a central controller. When the controller says "run these tests," the agent wakes up and runs them.
When the controller says "deploy this new version of the app," the agent downloads the files and installs them. The agent reports back what happened, success or failure, so you always know the status. Agents are used in many areas like monitoring (checking if a website is up), security (scanning for viruses), and DevOps (building and deploying code).
The key point is that agents run locally but are managed remotely. This saves you from having to log into each machine manually. Without agents, you would need to sit at every computer and type commands by hand.
With agents, you tell one central tool what to do, and the agents do the actual work on the target machines. This makes large-scale IT operations faster, more reliable, and less error-prone.
Full Technical Definition
In the context of Azure DevOps and modern DevOps practices, an agent is a software runtime that executes jobs defined in pipelines. The agent runs on a target machine, either a Windows, Linux, or macOS host, and communicates with the Azure DevOps server or service using HTTPS. The agent listens for incoming job requests from the Azure Pipelines orchestration engine.
When a job is triggered, the agent downloads the job definition, which includes tasks such as running scripts, compiling code, running tests, or publishing artifacts. The agent executes each task within a sandboxed environment, captures logs, and streams output back to the Azure DevOps portal in near real-time. Agents can be configured as either Microsoft-hosted (managed by Microsoft, automatically scaled) or self-hosted (installed on your own infrastructure).
Self-hosted agents give you more control over the runtime environment, including custom software dependencies, network access, and security policies. The agent software itself is open source and written primarily in cross-platform runtimes like .NET Core.
It communicates via the Azure DevOps REST API and uses WebSocket-like channels for live logging. Authentication is handled through a personal access token (PAT) or OAuth. Agents support capabilities, metadata tags (e.
g., "Java", "Windows Server 2019") that help the pipeline match jobs to suitable agents. When a pipeline demands an agent with specific capabilities, the orchestration engine selects a matching agent from the pool.
Each agent can run only one job at a time, but you can install multiple agents on the same machine by using separate service accounts and deployment directories. The agent lifecycle includes installation, configuration, starting the service, and periodic updates. Azure DevOps automatically updates hosted agents, but self-hosted agents require manual or automated update handling.
Agents are also used outside of Azure DevOps, for example, Puppet agents, Chef agents, and Ansible agents (though Ansible is typically agentless). In monitoring, agents like the Azure Monitor Agent or Prometheus Node Exporter collect metrics and forward them to central systems. The core pattern remains the same: a lightweight daemon that executes work locally under remote orchestration.
Real-Life Example
Imagine you run a small restaurant with three locations. You cannot be at every location at the same time, so you hire a shift manager at each restaurant. Every morning, you send a text message to each manager with the day's tasks: prep the vegetables, check inventory, clean the kitchen, and set up for lunch service.
The managers do the work, text you back when each task is done, and let you know if anything went wrong, like a broken fridge or missing ingredients. In this analogy, you are the central orchestration system (Azure DevOps). The shift managers are the agents.
Each manager lives at their respective restaurant (the target machine). They follow your instructions exactly and report back in real time. If you told a manager to prep vegetables but the manager had no knife (missing software dependency), they would report the failure.
If a manager quits (agent goes offline), you cannot run tasks at that location until you hire a replacement. The beauty of this system is that you can scale from one restaurant to a hundred without hiring more corporate staff, you just add more managers (agents) at each new location. Similarly, in DevOps, when you add more build servers or test machines, you install an agent on each, and your pipelines can immediately start using them.
The agents do not think or decide, they just execute. This removes the burden of manual work and reduces human error. It also gives you full visibility because every action is logged and reported back.
Without agents, you would have to drive to each restaurant, do the work yourself, or rely on phone calls that might be forgotten. The agent model makes IT operations as efficient as a well-run restaurant chain.
Why This Term Matters
In practical IT, especially in DevOps environments, agents are the backbone of automation. They allow teams to run thousands of builds, tests, and deployments every day without human intervention. This is critical for continuous integration and continuous delivery (CI/CD) because it means code changes can be automatically built, tested, and deployed to production in minutes.
Without agents, every step would require someone to log into a server and type commands, which is slow, error-prone, and does not scale. Agents also enable consistency. Because the same agent software runs on every target machine, the execution environment is predictable.
You can ensure that every build uses the same compiler version, the same dependencies, and the same test suite. This eliminates the "it works on my machine" problem. In monitoring, agents provide real-time visibility into system health.
The Azure Monitor Agent, for example, collects performance counters, event logs, and custom metrics from all your servers and sends them to a central Log Analytics workspace. This gives operations teams a single pane of glass to detect issues before users are affected. Agents also matter for security.
When you use self-hosted agents, you control where the code runs, inside your network, behind your firewall. This is essential for regulated industries that cannot send code to external cloud hosts. You can lock down the agent machine, restrict network access, and audit every job.
Agents support secure variable injection and secret management, so passwords and API keys never appear in logs. In short, agents are not just a convenience, they are a foundation for reliable, scalable, and secure automation. Any IT professional working with CI/CD, configuration management, or monitoring will encounter agents regularly.
How It Appears in Exam Questions
On the AZ-400 exam, agent questions typically appear in three patterns: configuration, scenario, and troubleshooting. Configuration questions: You might be asked to select the correct YAML syntax to specify agent demands. For example, "Which YAML key-value pair would ensure the pipeline runs only on an agent with the 'Java' capability installed?"
Answer: the 'demands' key with 'java' in the pool section. Another configuration question could ask: "How do you add a custom capability to a self-hosted agent?" The correct answer is to edit the .
capabilities file in the agent directory or use the agent configuration tool. Scenario questions: A company has a security policy that requires all code to be built and tested on machines inside the corporate network. Which agent solution should they use?
Answer: self-hosted agents. Another scenario: A team has a pipeline that builds a .NET Framework application, but the Microsoft-hosted agent does not have the exact Windows SDK version required.
What should they do? Answer: use a self-hosted agent with the specific SDK installed, or create a custom image for a hosted agent (if using Azure Pipelines). Troubleshooting questions: A pipeline is stuck in a 'waiting for agent' state.
What are possible causes? The agent pool may have no available agents, all agents may be busy, or agents may be offline due to network issues. Another common troubleshooting pattern: a build fails with 'Agent is lost' or 'No agent found matching demands'.
The cause is often missing capabilities on the agent, or the agent service has stopped. You might also see questions about agent upgrades: "You notice that a self-hosted agent is not receiving new jobs. What should you check?"
Answer: verify that the agent version is compatible with the Azure DevOps server version, and update the agent if needed. Some questions ask about agent pools vs. deployment groups.
You need to know that agents in a deployment group are specifically for release management to multiple servers, not for build jobs. Overall, expect 3–5 questions related to agents on the AZ-400 exam, spread across multiple sections. Mastery of agent concepts, configuration, and troubleshooting is essential.
Study AZ-400
Test your understanding with exam-style practice questions.
Example Scenario
A software company called CloudBase is developing a web application using ASP.NET Core. The team uses Azure DevOps for CI/CD. They have a build pipeline that compiles the code, runs unit tests, and produces a deployable package.
For the past week, the build has been failing randomly with the error: "The SDK 'Microsoft.NET.Sdk.Web' specified could not be found." The team discovers that the Microsoft-hosted agent they are using does not include the preview version of .
NET SDK that their project requires. The team lead decides to use a self-hosted agent on a dedicated virtual machine in their Azure subscription. An IT admin creates a Windows Server 2022 VM, installs the required .
NET SDK 7.0 preview, Visual Studio 2022 Build Tools, and the Azure DevOps agent software. The admin configures the agent with a capability called "DotNetPreview" set to "7.0-preview".
Then they register the agent with the team's Azure DevOps organization and add it to a new agent pool called "Build-Preview". The pipeline YAML is updated to target this pool: pool: name: 'Build-Preview' demands: DotNetPreview -equals 7.0-preview.
Now every time a developer pushes code, the pipeline runs on the self-hosted agent, which has the correct SDK. Builds succeed consistently. The team also sets up a cron job to update the agent software automatically.
This scenario illustrates how self-hosted agents solve software dependency issues, how capabilities ensure the right agent picks up the job, and the administrative steps needed to set up and maintain the agent. It also shows why understanding agents is crucial for real-world DevOps.
Common Mistakes
Using a Microsoft-hosted agent when custom software is required.
Microsoft-hosted agents have a fixed set of pre-installed tools. You cannot install custom software like a specific SDK version or proprietary libraries. The build will fail if a required tool is missing.
Switch to a self-hosted agent where you can install any software. Alternatively, use a custom VM image with Azure Image Builder for hosted agents.
Installing multiple agents on the same machine without changing the service account.
Each agent needs its own service account and data directory. If you use the same account, agents will conflict, leading to failed jobs and corrupted state.
When installing additional agents, use the --agent parameter with a unique name, create a separate service account, and specify a different working directory.
Forgetting to configure agent capabilities for self-hosted agents.
Pipelines often have demands for specific capabilities (e.g., Java, Docker). Without capabilities, the pipeline may never match to this agent, leaving jobs stuck in the queue.
Add capabilities during agent configuration via .capabilities file or through the Azure DevOps portal under Agent Pools > Agent > Capabilities.
Assuming self-hosted agents update automatically.
Self-hosted agents do not auto-update by default. If the Azure DevOps server upgrades the agent protocol, old agents may stop receiving jobs.
Set up a scheduled task or cron job to run the agent update script (./config.sh --upgrade or .\config.cmd --upgrade) periodically.
Not checking agent health before running a critical pipeline.
An offline or misconfigured agent causes pipeline delays. Without proactive monitoring, teams may lose hours debugging why jobs are not starting.
Use the Azure DevOps Agents tab to view agent status, restart the agent service, or set up alerts for offline agents.
Exam Trap — Don't Get Fooled
{"trap":"The exam asks: 'You want to run a build on an agent that has the Docker Desktop installed. Which pool type should you choose?' Learner sees 'Microsoft-hosted' as an option and thinks it supports Docker by default, but fails to realize the specific demand may not be met for all hosted agents."
,"why_learners_choose_it":"Microsoft-hosted agents do include Docker Desktop, but the learner overlooks that not all hosted images have it. Some images are Windows-only without Docker. Also, the exam may specifically require a self-hosted agent for compliance reasons."
,"how_to_avoid_it":"Always read the scenario carefully. If the question mentions custom software, specific OS versions, or network restrictions, lean towards self-hosted. If the scenario only says 'Docker' generally, confirm the hosted agent image supports it (e.
g., ubuntu-latest)."
Step-by-Step Breakdown
Install the agent software
Download the agent package from Azure DevOps (Agent Pools > Download agent). Choose the correct OS package (Windows .zip, Linux tar.gz, macOS .tar.gz). Extract it to a folder like 'C:\agents\agent1' or '/opt/azp/agent'.
Configure the agent
Run the configuration script (config.cmd on Windows, config.sh on Linux). You will be prompted for the Azure DevOps organization URL, personal access token (PAT), agent pool name, and agent name. This step registers the agent with the server.
Set agent capabilities (optional but recommended)
After configuration, edit the .capabilities file in the agent root directory to add custom metadata like 'DOCKER_INSTALLED=true' or 'JAVA_HOME=/usr/lib/jvm/java-11'. This helps pipeline demands match correctly.
Start the agent service
Run the agent service so it runs continuously in the background. On Windows, use '.\svc.bat install' and '.\svc.bat start'. On Linux, use 'sudo ./svc.sh install' and 'sudo ./svc.sh start'. The agent will now listen for jobs.
Verify agent in Azure DevOps
Go to Azure DevOps > Organization Settings > Agent Pools > select your pool. The agent should appear with status 'Online'. You can check its capabilities and view recent job history.
Update the agent periodically
Run the upgrade command (./config.sh --upgrade) or use a scheduled task to keep the agent compatible with the latest Azure DevOps server changes. Failure to update can cause the agent to go offline.
Practical Mini-Lesson
In practice, setting up and managing agents is a core DevOps skill. The most common scenario is installing a self-hosted agent on a VM or physical server that has specific software your pipeline needs. For example, a legacy .NET Framework app requiring Windows Server 2019 with Visual Studio 2019 Build Tools. You install the agent, configure it with capabilities like 'VS2019' and 'DotNetFramework', and then point your pipeline to use a pool that contains this agent.
One critical detail is agent isolation. If you have multiple pipelines running on the same agent machine, ensure they don't interfere. Each job runs in a new workspace folder, but environment variables and file system state can persist. To avoid contamination, set 'clean: true' in your pipeline steps or use containers. For self-hosted agents, you should also secure the machine: use a dedicated service account with least privilege, restrict network access to only the Azure DevOps URL, and enable Windows Firewall.
Another practical point is monitoring agent health. A common issue is the agent service stopping due to memory pressure or a crash. Set up a monitoring check that pings the agent or checks the service status. In Azure, you can use Azure Monitor to alert on agent offline events. Also, consider using agent pools for different environments: a 'Dev' pool for quick builds, a 'Test' pool for integration tests, and a 'Prod' pool for deployments. This prevents resource contention.
When scaling, you can install multiple agents on the same VM by creating separate directories and using different agent names. However, each agent consumes memory and CPU, so balance load. For high-availability, use multiple VMs in an agent pool with redundant agents. The Azure DevOps orchestration engine distributes jobs across available agents.
Professionals should also know how to replace an agent's PAT before expiry. If the PAT expires, the agent goes offline and stops accepting jobs. You can re-configure with a new PAT without reinstalling from scratch by running the configuration script again. Document all agent registration details in a secure vault. This practical knowledge is what separates a beginner from a seasoned DevOps engineer.
Memory Tip
Think 'Agent = Automated Genie Executing Tasks', the agent does the work for you, just like a genie that follows orders.
Covered in These Exams
Current Exam Context
Current exam versions that test this topic — use these objectives when studying.
Related Glossary Terms
A/B testing is a controlled experiment that compares two versions of a single variable to determine which one performs better against a predefined metric.
Two-factor authentication (2FA) is a security method that requires two different types of proof before granting access to an account or system.
AAA (Authentication, Authorization, and Accounting) is a security framework that controls who can access a network, what they are allowed to do, and tracks what they did.
802.1X is a network access control standard that authenticates devices before they are allowed to connect to a wired or wireless network.
Frequently Asked Questions
What is the difference between a Microsoft-hosted agent and a self-hosted agent?
Microsoft-hosted agents are managed by Microsoft and come with pre-installed tools. They are convenient and auto-scaled, but you cannot install custom software. Self-hosted agents run on your own infrastructure, giving you full control over software and security, but require maintenance.
Can I run multiple agents on the same machine?
Yes, you can install multiple agents by using different directories and unique agent names. Each agent needs its own service account. This is useful for maximizing hardware utilization.
How do I update a self-hosted agent?
Run the upgrade script from the agent directory: on Windows use .\config.cmd --upgrade, on Linux use ./config.sh --upgrade. Schedule this command to run regularly to keep the agent compatible.
What happens if the agent's PAT expires?
The agent will go offline and stop accepting jobs. You need to generate a new PAT and re-configure the agent by running the configuration script with the new token. No need to reinstall the agent software.
Why is my pipeline stuck in 'waiting for an agent'?
This usually means no agent in the selected pool matches the demands of the pipeline, or all agents are busy. Check that the agent pool has online agents with the required capabilities. Also ensure the pipeline YAML specifies the correct pool name.
Can I use a self-hosted agent with GitHub Actions?
Yes, GitHub Actions supports self-hosted runners, which are equivalent to self-hosted agents. The setup is similar: download the runner software, configure it with a token, and register it with your repository or organization.
Summary
An agent in DevOps is a lightweight software component that runs on a target machine to execute automated tasks such as builds, tests, and deployments. It acts as the bridge between a central orchestration system like Azure DevOps and the local environment where the actual work happens. Agents are essential for scaling CI/CD pipelines because they allow parallel execution across many machines without manual intervention. They come in two flavors: Microsoft-hosted (convenient, limited software) and self-hosted (customizable, more control). Understanding how to install, configure, and troubleshoot agents is a key skill for the AZ-400 exam and for real-world DevOps roles.
Agents matter because they enable consistency, speed, and security in automation. They ensure that every build uses the same environment, that deployments are repeatable, and that sensitive operations stay within your network. In exams, you will be tested on agent pools, capabilities, demands, and the difference between hosting options. Common mistakes include using the wrong agent type for custom software needs, forgetting to set capabilities, and neglecting agent updates.
The practical takeaway: whenever you see a pipeline job running, remember there is an agent somewhere doing the heavy lifting. Master the agent concept, and you will have a solid foundation for most DevOps automation scenarios.