Azure DevOps agents - Microsoft-hosted

August 22, 2023

In continuation to the previous article where we overviewed Azure DevOps agent, today - we will deep dive into the details of Microsoft-Hosted agent

Hardware and Software:

Azure Pipelines provides a default pool called "Azure Pipelines" for Microsoft-hosted agents.

The best part about Microsoft-Hosted agent is that it provides us with a range of virtual machine images to choose from and each of these images contains a standard set of tools and software

for example, The default image for a YAML build pipeline is ubuntu-latest.

After making a choice of VM we can use it in the pipeline as per the syntax below

pool:
  vmImage: ubuntu-latest 

It includes a huge list of tools and software which can be referred here.

The list is quite exhaustive however if we need to request additional software to be included in the image, that can be requested to Microsoft by creating an issue here.

Alternatively, tool installer tasks can also be used to install tool or runtime on the fly during every run of the pipeline

Following is an example of a task for installing Node.js

steps:
# Node install
- task: NodeTool@0
  displayName: Node install
  inputs:
    versionSpec: '14.x' # The version we're installing

another advantage of using a Microsoft-hosted agent is that a fresh VM is created for each job for every run of the pipeline and the VMs are discarded after use

This approach prevents issues with residual files however there cannot be any incremental logic in our pipelines (as the changes made by the job in the virtual machine will not be available for the next run)

Following are the key points to note regarding the hardware of Microsoft-hosted agents.

  • The VMs are located in the same geography as the Azure DevOps organization

    • Navigate to the following URL to see the organizations region

    azure devops region

    • Derive the geography for the mentioned region from here.

  • All the VMs are said to have at least 10GB of disk space, this is sufficient for a majority of use cases

    • In case 10GB isn't sufficient - we have two other options
      • self-hosted agents or scale set agents (a premium Microsoft-hosted agent variant)

Networking:

  • If we have a requirement to connect to any of our servers during the run of the pipeline, then we may need to open firewall for the Microsoft-hosted agent IPs

  • To determine the possible IPs download the JSON file from here.

    • Microsoft updates this file every week
    • From the geography (India) we identified earlier, determine all the regions under that geography and retrieve IPs for each of them
    • In our case India has two active regions as given below
      • South India (in Chennai) and Central India (in Pune)
    • we will search the JSON for "AzureDevOps.SouthIndia" and "AzureDevOps.CentralIndia" then collect the associated IPs
{
      "name": "AzureDevOps.SouthIndia",
      "id": "AzureDevOps.SouthIndia",
      "properties": {
        "changeNumber": 1,
        "region": "southindia",
        "regionId": 22,
        "platform": "Azure",
        "systemService": "AzureDevOps",
        "addressPrefixes": [
          "20.41.194.0/24"
        ],
        "networkFeatures": null
      }
},
{
      "name": "AzureDevOps.CentralIndia",
      "id": "AzureDevOps.CentralIndia",
      "properties": {
        "changeNumber": 1,
        "region": "centralindia",
        "regionId": 21,
        "platform": "Azure",
        "systemService": "AzureDevOps",
        "addressPrefixes": [
          "20.204.197.192/26"
        ],
        "networkFeatures": null
      }
}
  • These IPs can be used to configure firewall e.t.c required to connect the agent to our servers
  • Please note that the traffic between Microsoft-agent and our servers will be over public network

Cost:

Please refer to the following image regarding the cost to use a Microsoft-hosted agent

cost of microsoft hosted agent

basically, a free parallel job that can run up to 60 mins each time (with a cap of 30 hours per month) is available to start with.

Later, if we need additional capacity we can purchase it * The first parallel job purchase will remove the monthly cap and each job can run upto 6 hours however the parallelism will still be 1 * If we need parallelism at least two parallel jobs have to be purchased

The following are the factors to be considered while deciding on the parallelism required

  • Number of developers in the organization

    • The more the number of developers,the more the pull requests and hence more parallelism will be required in the pipeline
  • Pool consumption report

    • Navigate to Azure DevOps → <your_organization> → Settings → Agent pools → Azure Pipelines → Analytics tab
    • Verify the Queued Jobs against the Concurrency in the report, if there is a big backlog of queued jobs then more parallel jobs may need to be purchased

Summary:

At a very high level following are the pros and cons of Microsoft-hosted agents

Pros:

  • easy to setup and configure
  • maintainance is taken care of completely by Microsoft
  • provides a free tier

Cons:

  • cannot connect to the VMs remotely
  • cannot include the VMs in the corporate network
  • limited customization options

Thanks for reading, Goodbye until next week!


Profile picture

Written by Thillai Madhavan who lives and works in India. Stay updated by following him on LinkedIn.

All the information on this website - OrganicDevops.com - is published in good faith and for general information purposes only. OrganicDevops.com does not make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this website (OrganicDevops.com), is strictly at your own risk. OrganicDevops.com will not be liable for any losses and/or damages in connection with the use of our website. From our website, you can visit other websites by following hyperlinks to such external sites. While we strive to provide only quality links to useful and ethical websites, we have no control over the content and nature of these sites. These links to other websites do not imply a recommendation for all the content found on these sites. Site owners and content may change without notice and may occur before we have the opportunity to remove a link that may have gone 'bad'. Please be also aware that when you leave our website, other sites may have different privacy policies and terms which are beyond our control. Please be sure to check the Privacy Policies of these sites as well as their "Terms of Service" before engaging in any business or uploading any information. By using our website, you hereby consent to our disclaimer and agree to its terms. Should we update, amend or make any changes to this document, those changes will be prominently posted here
© 2024, OrganicDevOps