I'm using KEDA to add build agents dynamically to an agent pool as specified in Autoscaling Azure Pipelines agents with KEDA.
As mentioned on the article, the Azure Pipelines scaler supports scaling to zero but you need at least one agent registered in the agent pool in order for new jobs to be scheduled on the pool, otherwise a similar error will be displayed:
##[error]No agent found in pool xxxxxxx which satisfies the specified demands: Agent.Version -gtVersion x.xxx.x
What would be the best strategy/workaround to register some sort of dummy build agent in a pool that would be disabled and offline?
Consider using the Agents - ADD REST API to register an agent in a disabled state.
POST: /{organization}/_apis/distributedtask/pools/{poolId}/agents?api-version=7.1
{
"name": "dummy",
"status": "offline",
"enabled": false,
"version": "3.234.0" // or newer version
}
Though, the enabled flag isn't respected. You may need to patch the agent to disable it.
PATCH: /{organization}/_apis/distributedtask/pools/{poolId}/agents/{agentId}?api-version=7.1
{
"id": <agent id>,
"enabled": false
}