你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
DeviceManagementClient.StartLogCollection 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在指定设备上启动设备诊断日志收集。
public virtual Azure.Response StartLogCollection (string logCollectionId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member StartLogCollection : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.StartLogCollection : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function StartLogCollection (logCollectionId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response
参数
- logCollectionId
- String
日志集合标识符。
- content
- RequestContent
要作为请求正文发送的内容。 请求正文架构的详细信息,请参阅下面的“备注”部分。
- context
- RequestContext
请求上下文,它可以基于每个调用替代客户端管道的默认行为。
返回
从服务返回的响应。 响应正文架构的详细信息位于下面的“备注”部分。
例外
logCollectionId
或 content
为 null。
logCollectionId
是一个空字符串,预期为非空。
服务返回了不成功状态代码。
示例
此示例演示如何使用所需的参数和请求内容调用 StartLogCollection,以及如何分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceManagementClient(endpoint, "<instanceId>", credential);
var data = new {
deviceList = new[] {
new {
deviceId = "<deviceId>",
}
},
};
Response response = client.StartLogCollection("<logCollectionId>", RequestContent.Create(data));
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("deviceList")[0].GetProperty("deviceId").ToString());
此示例演示如何使用所有参数和请求内容调用 StartLogCollection,以及如何分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceManagementClient(endpoint, "<instanceId>", credential);
var data = new {
operationId = "<operationId>",
deviceList = new[] {
new {
deviceId = "<deviceId>",
moduleId = "<moduleId>",
}
},
description = "<description>",
};
Response response = client.StartLogCollection("<logCollectionId>", RequestContent.Create(data));
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("operationId").ToString());
Console.WriteLine(result.GetProperty("deviceList")[0].GetProperty("deviceId").ToString());
Console.WriteLine(result.GetProperty("deviceList")[0].GetProperty("moduleId").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("lastActionDateTime").ToString());
Console.WriteLine(result.GetProperty("status").ToString());
注解
下面是请求和响应有效负载的 JSON 架构。
请求正文:
的 LogCollection
架构:
{
operationId: string, # Optional. The log collection id.
deviceList: [
{
deviceId: string, # Required. Device Id
moduleId: string, # Optional. Module Id
}
], # Required. Array of Device Update agent ids
description: string, # Optional. Description of the diagnostics operation.
createdDateTime: string, # Optional. The timestamp when the operation was created.
lastActionDateTime: string, # Optional. A timestamp for when the current state was entered.
status: "NotStarted" | "Running" | "Succeeded" | "Failed", # Optional. Operation status.
}
响应正文:
的 LogCollection
架构:
{
operationId: string, # Optional. The log collection id.
deviceList: [
{
deviceId: string, # Required. Device Id
moduleId: string, # Optional. Module Id
}
], # Required. Array of Device Update agent ids
description: string, # Optional. Description of the diagnostics operation.
createdDateTime: string, # Optional. The timestamp when the operation was created.
lastActionDateTime: string, # Optional. A timestamp for when the current state was entered.
status: "NotStarted" | "Running" | "Succeeded" | "Failed", # Optional. Operation status.
}