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

DeviceManagementClient.GetOperationStatuses 方法

定义

获取所有设备导入操作的列表。 在自动删除之前,已完成的操作将保留 7 天。

public virtual Azure.Pageable<BinaryData> GetOperationStatuses (string filter = default, int? top = default, Azure.RequestContext context = default);
abstract member GetOperationStatuses : string * Nullable<int> * Azure.RequestContext -> Azure.Pageable<BinaryData>
override this.GetOperationStatuses : string * Nullable<int> * Azure.RequestContext -> Azure.Pageable<BinaryData>
Public Overridable Function GetOperationStatuses (Optional filter As String = Nothing, Optional top As Nullable(Of Integer) = Nothing, Optional context As RequestContext = Nothing) As Pageable(Of BinaryData)

参数

filter
String

限制返回的操作集。 仅支持一个特定筛选器:“状态 eq 'NotStarted' 或状态 eq 'Running'”。

top
Nullable<Int32>

指定一个非负整数 n,用于限制从集合返回的项数。 服务返回的可用项数最多不超过指定值 n。。

context
RequestContext

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

返回

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

例外

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

示例

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

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.GetOperationStatuses())
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("operationId").ToString());
    Console.WriteLine(result.GetProperty("status").ToString());
    Console.WriteLine(result.GetProperty("lastActionDateTime").ToString());
    Console.WriteLine(result.GetProperty("createdDateTime").ToString());
}

此示例演示如何使用所有参数调用 GetOperationStatuses,以及如何分析结果。

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.GetOperationStatuses("<filter>", 1234))
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("operationId").ToString());
    Console.WriteLine(result.GetProperty("status").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("message").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("errorDetail").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("occurredDateTime").ToString());
    Console.WriteLine(result.GetProperty("traceId").ToString());
    Console.WriteLine(result.GetProperty("lastActionDateTime").ToString());
    Console.WriteLine(result.GetProperty("createdDateTime").ToString());
    Console.WriteLine(result.GetProperty("etag").ToString());
}

注解

下面是可分页响应中一项的 JSON 架构。

响应正文:

DeviceOperationsListValue架构:

{
              operationId: string, # Required. Operation Id.
              status: "NotStarted" | "Running" | "Succeeded" | "Failed", # Required. Operation status.
              error: {
                code: string, # Required. Server defined error code.
                message: string, # Required. A human-readable representation of the error.
                target: string, # Optional. The target of the error.
                details: [Error], # Optional. An array of errors that led to the reported error.
                innererror: {
                  code: string, # Required. A more specific error code than what was provided by the containing error.
                  message: string, # Optional. A human-readable representation of the error.
                  errorDetail: string, # Optional. The internal error or exception message.
                  innerError: InnerError, # Optional. An object containing more specific information than the current object about the error.
                }, # Optional. An object containing more specific information than the current object about the error.
                occurredDateTime: string (ISO 8601 Format), # Optional. Date and time in UTC when the error occurred.
              }, # Optional. Operation error encountered, if any.
              traceId: string, # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting.
              lastActionDateTime: string (ISO 8601 Format), # Required. Date and time in UTC when the operation status was last updated.
              createdDateTime: string (ISO 8601 Format), # Required. Date and time in UTC when the operation was created.
              etag: string, # Optional. Operation ETag.
            }

适用于