你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

LoadTestRunClient.GetAppComponentsAsync(String, RequestContext) 方法

定义

获取关联的应用组件 (给定测试运行的 azure 资源) 集合。

public virtual System.Threading.Tasks.Task<Azure.Response> GetAppComponentsAsync (string testRunId, Azure.RequestContext context = default);
abstract member GetAppComponentsAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetAppComponentsAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetAppComponentsAsync (testRunId As String, Optional context As RequestContext = Nothing) As Task(Of Response)

参数

testRunId
String

负载测试运行的唯一名称只能包含小写字母、数字、下划线或连字符字符。

context
RequestContext

请求上下文,它可以基于每个调用替代客户端管道的默认行为。

返回

从服务返回的响应。 响应正文架构的详细信息位于下面的“备注”部分。

例外

testRunId 为 null。

testRunId 是一个空字符串,预期为非空。

服务返回了不成功状态代码。

示例

此示例演示如何使用所需的参数调用 GetAppComponentsAsync 并分析结果。

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new LoadTestRunClient(endpoint, credential);

Response response = await client.GetAppComponentsAsync("<testRunId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("resourceId").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("resourceName").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("resourceType").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("resourceGroup").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("subscriptionId").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("testRunId").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("createdBy").ToString());
Console.WriteLine(result.GetProperty("lastModifiedDateTime").ToString());
Console.WriteLine(result.GetProperty("lastModifiedBy").ToString());

注解

下面是响应有效负载的 JSON 架构。

响应正文:

TestRunAppComponents架构:

{
  components: Dictionary<string, AppComponent>, # Required. Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } 
  testRunId: string, # Optional. Test run identifier
  createdDateTime: string (ISO 8601 Format), # Optional. The creation datetime(ISO 8601 literal format).
  createdBy: string, # Optional. The user that created.
  lastModifiedDateTime: string (ISO 8601 Format), # Optional. The last Modified datetime(ISO 8601 literal format).
  lastModifiedBy: string, # Optional. The user that last modified.
}

适用于