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

DeviceManagementClient.GetLogCollections(RequestContext) 方法

定义

获取所有设备诊断日志集合。

public virtual Azure.Pageable<BinaryData> GetLogCollections (Azure.RequestContext context = default);
abstract member GetLogCollections : Azure.RequestContext -> Azure.Pageable<BinaryData>
override this.GetLogCollections : Azure.RequestContext -> Azure.Pageable<BinaryData>
Public Overridable Function GetLogCollections (Optional context As RequestContext = Nothing) As Pageable(Of BinaryData)

参数

context
RequestContext

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

返回

Pageable<T>包含对象列表的服务中的 BinaryData 。 集合中每个项的正文架构的详细信息,请参阅下面的“备注”部分。

例外

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

示例

此示例演示如何调用 GetLogCollections 并分析结果。

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

foreach (var data in client.GetLogCollections())
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).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 架构。

响应正文:

LogCollectionListValue架构:

{
              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.
            }

适用于