客户端库 - 用于获取连接的服务详细信息 [英] Client library - for getting connected service details
问题描述
我正在使用Microsoft.VisualStudio.Services.Release.Client nuget包以编程方式按发布定义ID查询发布定义。
I am using Microsoft.VisualStudio.Services.Release.Client nuget package to programatically query a release definition by release definition Id.
在一个相关定义中我发现ConnectedService对象(这基本上有一个Id,通过使用Id,我可以进行http REST调用,并可以获得azure订阅详细信息 - 如订阅名称和ID)
Inside a relase definition I find ConnectedService object ( this basically has an Id and by using that Id I can make a http REST call and can get the azure subscription details - like subscription name and Id )
我是什么寻找 - 而不是进行http REST API调用我想使用客户端库。我不确定使用哪个库以及类型是什么
What I am looking for - instead of making a http REST API call I want to use the client library. I am not sure which library to use and what is the type
代码:
这就是我现在可以做的事情:
This is what I can do now:
(我收到一个回复字符串,它给出了azure订阅ID和名称)
( I get a response string which gives me the azure subscription Id and name )
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; var azureSubUrl = @" https://hhhuuuu.visualstudio.com/< project guid> / _ apis / distributedtask / serviceendpoints /< connected service guid我从发布定义>"" ;; $
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;使用(HttpClient client = new HttpClient())
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue ("application / json"));
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(" Basic",&
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format(" {0}:{1}" ;,"",personalaccesstoken))));
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;使用(HttpResponseMessage响应= client.GetAsync(
azureSubUrl ).Result)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; response.EnsureSuccessStatusCode();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string responseBody = await response.Content.ReadAsStringAsync();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(responseBody);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
var azureSubUrl = @"https://hhhuuuu.visualstudio.com/<project guid>/_apis/distributedtask/serviceendpoints/<connected service guid I get from Release definition>";
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "", personalaccesstoken))));
using (HttpResponseMessage response = client.GetAsync(
azureSubUrl).Result)
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
我想做什么:
而不是使用我想要的HttpClient客户端使用库中的特定客户端,并在客户端库中使用响应对象的类型。类似于我获取发布定义的内容
Instead of using that HttpClient client I want to use a specific client in the library and use a type in the client library for the response object. Similar to what I do for getting release definition
ReleaseHttpClient rmClient = connection.GetClient< ReleaseHttpClient>()
ReleaseDefinitions releaseDefinition = rmClient.GetReleaseDefinitionAsync(
ReleaseHttpClient rmClient = connection.GetClient<ReleaseHttpClient>()
ReleaseDefinitions releaseDefinition = rmClient.GetReleaseDefinitionAsync(
如何使用(以及使用哪个客户端库)获取连接的服务详细信息?
How to use ( and what client library to use ) for getting connected service details ?
推荐答案
HI MSTechT,
HI MSTechT,
感谢您在此发帖。
没有客户端api /库来查询有关发布/发布定义的信息。我们只能使用Rest api查询连接的服务详细信息。感谢您的支持理解。
There is no client api/library to query the information about Release/Release definition. We could only use the Rest api to query the connected service details. Thank you for your understanding.
最好的问候
Limitxiao Gao
Limitxiao Gao
>
这篇关于客户端库 - 用于获取连接的服务详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!