Search code examples
c#tfsazure-devopsazure-devops-rest-apiazure-devops-server-2019

How to create Agent Pool in Azure DevOps via C# client?


How to create Agent Pool in Azure DevOps via C# client?

I find some raw rest api for agent pool like this documentation.

But I want to create agent pool via C# client.

Now I use Microsoft.TeamFoundationServer.ExtendedClient library, but can not find the solution.


Solution

  • You need also the Microsoft.TeamFoundation.DistributedTask.WebApi nuget package:

    VssConnection connection = new VssConnection(new Uri("URL"), new VssCredentials());
    var client = connection.GetClient<TaskAgentHttpClient>();
    client.AddAgentPoolAsync(new TaskAgentPool("TestPool"));