Thursday, October 1, 2020

Getting Started with Azure Scale Set Agents

Azure DevOps pipelines use hosted agents or private agents to run the build steps. However, while using the private agents one of the main challenges faced by the users is cost of the agents. As a solution to this we can use Azure Scale set agents as describe in this post. Scale set will create agents on demand and destroy them after use.
  • First create a VM with all the required software installed in it.
  • Open Azure Cloud Shell and execute following commands.
    • Run following command to select relevant subscription if you have multiple subscriptions.

az account set -s <your subscription ID>  

    • Create resource group to isolate all the resources linked with scale set agent.


az group create --location <location> --name <myresourcegroup>
    • Create scale set agents using the VM image.


az vmss create --resource-group <myresourcegroup> --name <myscalesetname> --image <mycustomvmimage> --admin-username <myuser> --admin-password <mypassword> --instance-count <count> --disable-overprovision --upgrade-policy-mode manual --load-balancer '""'

  • Once command executed successfully, scale set will be provisioned similar to follows.

  • Now move to the Azure DevOps project settings and go to Agent pools.
  • Click on Add pools to add new pool.


  • Pane will be opened to enter new pool details. Select scale set and give other relevant  information.


1 - Select scale set from the drop down
2 - Give name for the agent pool
3 - If selected "Automatically teat down virtual machines after every use" .It will delete the agent after use
4 - Maximum number of VMs create in the scale set on demand
5 - Number of VMs up and running in the scale set on idle state

You can use this agent pool in Azure DevOps builds and releases. Once build is triggered, agents will be provisioned on demand. Once build is completed, it will discard after some time. Hence, azure scale set agent users can use private agents in a cost effective way.

No comments:

Post a Comment