DEV Community

Cover image for Microsoft Hosted Agents or Self-Hosted Agents
Mo
Mo

Posted on

Microsoft Hosted Agents or Self-Hosted Agents

If you are using Azure Pipelines to build and deploy your software, you need to choose between Microsoft-hosted agents and self-hosted agents. In this blog post, I will explain the difference between them and when you should use each one.

Microsoft Hosted Agents:

Microsoft-hosted agents are virtual machines that are managed by Microsoft and run in the cloud. They have a predefined set of tools and software installed, and they are updated regularly. You can select from different images, such as Windows, Linux, or macOS, depending on your needs. Each time you run a pipeline, you get a fresh VM for each job, and the VM is discarded after the job is done. This means that you don't have to worry about maintenance, upgrades, or security patches. However, it also means that you can't install any custom software or dependencies on the agent, and you have to deal with potential network latency or bandwidth issues.

Self-Hosted Agents:

Self-hosted agents are virtual machines or physical machines that you set up and manage on your own. You can install any software or tools that you need for your builds and deployments, and you have full control over the hardware, operating system, and configuration. You can also leverage machine-level caches and configuration to speed up your pipelines. However, you also have to take care of updating, securing, and scaling your agents, which can be time-consuming and costly.

When to Use Self-Hosted or Microsoft Hosted Agents

So, when should you use Microsoft-hosted agents or self-hosted agents? Here are some factors to consider:

  • Complexity: If your pipelines require complex or custom software or tools that are not available on the Microsoft-hosted agents, you should use self-hosted agents. For example, if you need to use a specific version of Java or Python, or if you need to access a local database or service.
  • Performance: If your pipelines are sensitive to performance or network issues, you should use self-hosted agents. For example, if you need to transfer large files or data sets, or if you need to run CPU-intensive or memory-intensive tasks.
  • Cost: If your pipelines run frequently or for long durations, you should use self-hosted agents. For example, if you have a high number of parallel jobs or if you need to run long-running tests or simulations. Microsoft-hosted agents are free for the first 1,800 minutes per month per organization, but after that you have to pay for additional minutes or parallel jobs.
  • Security: If your pipelines handle sensitive or confidential data or code, you should use self-hosted agents. For example, if you need to comply with certain regulations or policies, or if you need to access restricted resources or networks.

Summary of Differences:

To summarize, Microsoft-hosted agents are convenient and easy to use, but they have some limitations in terms of complexity, performance, cost, and security. Self-hosted agents are flexible and powerful, but they require more effort and resources to maintain and manage.

If you have any questions or feedback, please leave a comment below.

Thank you for reading!

Top comments (0)