DeviceManagementClient.GetOperationStatusAsync Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Récupérer les status d’opération.
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)
Paramètres
- operationId
- String
Identificateur d'opération.
Définit la condition If-None-Match. L’opération n’est effectuée que si l’ETag sur le serveur ne correspond pas à cette valeur.
- context
- RequestContext
Contexte de requête, qui peut remplacer les comportements par défaut du pipeline client par appel.
Retours
Réponse retournée par le service. Les détails du schéma du corps de la réponse se trouvent dans la section Remarques ci-dessous.
Exceptions
operationId
a la valeur null.
operationId
est une chaîne vide, et on s’attendait à ce qu’elle ne soit pas vide.
Le service a retourné un code de status non réussi.
Exemples
Cet exemple montre comment appeler GetOperationStatusAsync avec les paramètres requis et analyser le résultat.
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());
Cet exemple montre comment appeler GetOperationStatusAsync avec tous les paramètres et comment analyser le résultat.
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());
Remarques
Vous trouverez ci-dessous le schéma JSON pour la charge utile de réponse.
Corps de réponse :
Schéma pour 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.
}
S’applique à
Azure SDK for .NET