你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
DeviceManagementClient.GetOperationStatusAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
检索操作状态。
public virtual System.Threading.Tasks.Task<Azure.Response> GetOperationStatusAsync (string operationId, Azure.ETag? ifNoneMatch = default, Azure.RequestContext context = default);
abstract member GetOperationStatusAsync : string * Nullable<Azure.ETag> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetOperationStatusAsync : string * Nullable<Azure.ETag> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetOperationStatusAsync (operationId As String, Optional ifNoneMatch As Nullable(Of ETag) = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
参数
- operationId
- String
操作标识符。
- context
- RequestContext
请求上下文,它可以基于每个调用替代客户端管道的默认行为。
返回
从服务返回的响应。 响应正文架构的详细信息位于下面的“备注”部分。
例外
operationId
为 null。
operationId
是一个空字符串,预期为非空。
服务返回了不成功状态代码。
示例
此示例演示如何使用所需参数调用 GetOperationStatusAsync 并分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceManagementClient(endpoint, "<instanceId>", credential);
Response response = await client.GetOperationStatusAsync("<operationId>");
JsonElement result = JsonDocument.Parse(response.ContentStream).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());
此示例演示如何使用所有参数调用 GetOperationStatusAsync,以及如何分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceManagementClient(endpoint, "<instanceId>", credential);
Response response = await client.GetOperationStatusAsync("<operationId>", null);
JsonElement result = JsonDocument.Parse(response.ContentStream).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 架构。
响应正文:
的 DeviceOperation
架构:
{
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.
}