Understanding Microsoft-hosted vs. Self-hosted Agents in Azure DevOps
When working with Azure DevOps Pipelines, the concept of agents is fundamental. These agents are responsible for running your builds, tests, and deployments. Azure DevOps provides two main options:
-
Microsoft-hosted agents
-
Self-hosted agents
Let’s explore both options in detail, compare them, and see when to use which.
1. What is an Agent in Azure DevOps?
An agent is essentially a machine (VM or physical) that runs pipeline jobs. It checks out code, installs dependencies, runs scripts, and performs deployments.
2. Microsoft-hosted Agents
These are virtual machines maintained by Microsoft, automatically spun up on demand.
Key Features:
-
No setup required – Just define the
vmImage
in your pipeline. -
Pre-installed tools like .NET, Node.js, Python, Java, Azure CLI, Docker, and more.
-
Clean environment – Every run gets a fresh VM.
-
Auto-scaled – No need to worry about parallelism or load balancing.
-
Billing – Free tier available with limited minutes; beyond that, usage is billed.
Example Usage:
Microsoft will allocate a VM with the latest Windows OS and tools for your pipeline run.
3. Self-hosted Agents
Self-hosted agents are machines (on-premises or cloud VMs) that you configure and manage yourself.
Key Features:
-
Full control over installed software, environments, and network access.
-
Persistent tools and cache, improving build performance.
-
No auto-scaling – you’re responsible for provisioning and maintaining agents.
-
Ideal for:
-
Working behind firewalls or in isolated environments.
-
Projects requiring non-standard tools.
-
Reducing costs with long-running build agents.
-
Example Usage:
You must register your machine to the SelfHostedAgentPool
and install the Azure Pipelines agent manually.
4. Comparison Table
Feature | Microsoft-hosted Agent | Self-hosted Agent |
---|---|---|
Maintenance | Microsoft | You manage it |
Environment | Fresh VM per job | Persistent machine |
Custom Software | Limited | Full control |
Tool Availability | Pre-installed | You install manually |
Cost | Free/minutes billed | No per-minute billing |
Performance | Slower (due to setup time) | Faster (cached dependencies, tools) |
Best For | Simplicity, quick setups | Custom, high-performance, secure jobs |
5. Which Should You Choose?
-
Go with Microsoft-hosted agents if:
-
You want minimal setup.
-
Your builds use common tools.
-
You’re OK with a clean VM every time.
-
-
Choose Self-hosted agents if:
-
You need special software or networking.
-
You want faster builds with persistent caching.
-
You want to reduce pipeline execution costs in the long run.
-
Conclusion
Both agent types offer value depending on your needs. Microsoft-hosted agents are perfect for convenience and general workloads, while self-hosted agents shine in performance, customization, and cost-effectiveness for complex or large-scale builds.
Whether you’re building a microservice, deploying to Kubernetes, or just running some tests, choosing the right agent model is key to optimizing your CI/CD workflows
Comments
Post a Comment