Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
ReleaseHttpClient is public as nuget package : https://www.nuget.org/packages/Microsoft.VisualStudio.Services.Release.Client
GitHub samples: https://github.com/chandan-anjani/VSTSRMAPISample
Fetching release definitions using given credential :-
Step1: Create one 'Windows Console Application' using Visual studio 2015
Step2: Goto Tools -->NuGet Package Manager --> Manage NuGet Packages for Solutions --> Browse (make sure Package source: nuget.org)
Step3: Search and Install following package to your solution
Step4: Add following code to fetch all release definitions for a given project. Please update your tenant and project name in below sample.
using System;
using Microsoft.VisualStudio.Services.Client;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.Clients;
namespace ReleaseHttpClientSample
{
class Program
{
static void Main(string[] args)
{
Uri serverUrl = new Uri("https://{your tenant name}.visualstudio.com");
VssCredentials credentials = new VssClientCredentials();
credentials.Storage = new VssClientCredentialStorage();
VssConnection connection = new VssConnection(serverUrl, credentials);
ReleaseHttpClient rmClient = connection.GetClient<ReleaseHttpClient>();
var releaseDefinitions = rmClient.GetReleaseDefinitionsAsync("{your project name}").Result;
Console.Out.WriteLine("Release definitions " + releaseDefinitions.Count);
}
}
}
Step5: Done
Adding a variable to a given release using PAT Token :-
Follow Step1 to Step3 above
Step4:-
using System;
using Microsoft.VisualStudio.Services.Client;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.Clients;
namespace ReleaseHttpClientSample
{
class Program
{
static void Main(string[] args)
{
string collectionUri = args[0];
string projectName = args[1];
string patToken = args[2];
int releaseId = int.Parse(args[3]);
VssConnection connection = new VssConnection(new Uri(collectionUri), new VssBasicCredential("username", patToken));
ReleaseHttpClient client = connection.GetClient<ReleaseHttpClient>();
var release = client.GetReleaseAsync(projectName, releaseId).Result;
var variableValue = new ConfigurationVariableValue();
variableValue.Value = "bar";
release.Variables.Add("foo", variableValue);
var updatedRelease = client.UpdateReleaseAsync(release, projectName, releaseId).Result;
}
}
}
Step5: Done
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in