Search code examples
c#visual-studioazure-devopsazure-devops-rest-api

Get CurrentStatus of AzureDevOps-Agent


Is there a way to find out the "Current Status" of an agent (Microsoft.TeamFoundation.DistributedTask.WebApi.TaskAgent) via the AzureDevOps WebApi? ScreenShot

Unfortunately, so far I have only found the option to set the status and not to read it. https://learn.microsoft.com/en-us/dotnet/api/microsoft.teamfoundation.distributedtask.webapi.taskagenthttpclientbase.updateagentupdatestateasync?view=azure-devops-dotnet

I would be grateful for any information. Best regards Paddy


Solution

  • Is there a way to find out the "Current Status" of an agent

    Yes. You can use the method: TaskAgentHttpClientBase.GetAgentsAsync and set the includeAssignedRequest to true.

    To determine if the agent is Idel or busy, you can check the AssignedRequest value in the response.

    If the AssignedRequest value is null or empty, this means that the agent is in Idle State.

    If the AssignedRequest returns the content, this means that the agent is running the related builds.