AzDoAgentScaler is a CLI that enables dynamic scaling of Azure DevOps self-hosted agents using Docker containers.
The goal is to optimize resource usage and costs by automatically creating and removing agent instances depending on the build and release workload in Azure DevOps organization.
It continuously monitors the number of online agents and waiting jobs in a specified agent pool, ensuring that:
- A minimum number of agents are always running (
MinAgents). - Additional agents are created when there are waiting jobs, up to a maximum limit (
MaxAgents). - Idle agents are removed when there are no jobs and the number of agents exceeds the minimum.
This tool only supports Docker images hosted on Docker Hub, making it compatible with publicly available agent images or any custom images pushed to Docker Hub.
- Automatic scaling of Azure DevOps self-hosted agents running in Docker containers.
- Ensures a minimum number of agents (
MinAgents) are always online, regardless of job queue. - Automatically scales up additional agents when there are waiting jobs and the number of agents is below the maximum (
MaxAgents). - Scales down idle agents when there are no waiting jobs and the number of agents exceeds the minimum.
- Integrates with the Azure DevOps API to monitor jobs, agent pools, and agent status in real-time.
- Supports Docker Hub images only, allowing the use of official or custom agent images published to Docker Hub.
azdoagentscaler.mp4
Before running AzDoAgentScaler, make sure you have the following:
-
Docker installed and running on the machine or server where the scaler will execute.
-
Azure DevOps configured with self-hosted agents and parallelism enabled in your plan.
-
An Azure DevOps Personal Access Token (PAT) with at least the following scopes:
Agent Pools (Read, Manage)Build (Read)Release (Read)
Once you download the release for your platform, you can run the CLI directly.
AzDoAgentScaler.exe --org "your-organization" --pat "personal-access-token" --poolName "agent-pool-name"./AzDoAgentScaler --org "your-organization" --pat "personal-access-token" --poolName "agent-pool-name" | Option | Required | Description |
|---|---|---|
--org |
✅ | Azure DevOps organization name |
--pat |
✅ | Personal Access Token (PAT) with required permissions |
--poolName |
✅ | Name of the Agent Pool in Azure DevOps |
--minAgents |
❌ (default: 1) | Minimum number of agents to keep online |
--maxAgents |
❌ (default: 5) | Maximum number of agents allowed |
--interval |
❌ (default: 30) | Interval (in seconds) between scaling checks |
--dockerImage |
❌ (default: mcr.microsoft.com/azure-pipelines/vsts-agent) |
Docker Hub image to use for agent containers |
-
Monitor agents and jobs
TheAgentScalercontinuously checks:- The number of online agents in the specified Azure DevOps agent pool.
- The number of waiting jobs in the build and release queues.
-
Ensure minimum agents
If the number of online agents is less thanMinAgents, new agents are automatically created, regardless of waiting jobs. -
Scale up for workload
If there are waiting jobs and the number of online agents is belowMaxAgents, new agents are created to handle the workload. -
Scale down idle agents
When there are no waiting jobs and the number of online agents exceedsMinAgents, idle agents are removed to save resources. -
No action needed
If online agents equalMinAgentsand there are no waiting jobs, the scaler takes no action.
Feedback, suggestions, and contributions!
- If you have ideas for new features or improvements, please open an issue and describe your suggestion.
- Feel free to submit pull requests if you want to contribute code or fixes.

