DeviceManagementClient.GetDeviceModule(String, String, RequestContext) 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.
Obtient les propriétés du module d’appareil et les dernières status de déploiement pour un module d’appareil connecté à Device Update pour IoT Hub.
public virtual Azure.Response GetDeviceModule (string deviceId, string moduleId, Azure.RequestContext context = default);
abstract member GetDeviceModule : string * string * Azure.RequestContext -> Azure.Response
override this.GetDeviceModule : string * string * Azure.RequestContext -> Azure.Response
Public Overridable Function GetDeviceModule (deviceId As String, moduleId As String, Optional context As RequestContext = Nothing) As Response
Paramètres
- deviceId
- String
Identificateur de l’appareil dans Azure IoT Hub.
- moduleId
- String
Identificateur de module d’appareil dans Azure IoT Hub.
- context
- RequestContext
Contexte de la demande, 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
deviceId
ou moduleId
est null.
deviceId
ou moduleId
est une chaîne vide, et était censé être non vide.
Le service a retourné un code de status non réussi.
Exemples
Cet exemple montre comment appeler GetDeviceModule 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 = client.GetDeviceModule("<deviceId>", "<moduleId>");
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("deviceId").ToString());
Console.WriteLine(result.GetProperty("moduleId").ToString());
Console.WriteLine(result.GetProperty("deviceClassId").ToString());
Console.WriteLine(result.GetProperty("groupId").ToString());
Console.WriteLine(result.GetProperty("lastAttemptedUpdate").GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("lastAttemptedUpdate").GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("lastAttemptedUpdate").GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("lastAttemptedUpdate").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("lastAttemptedUpdate").GetProperty("friendlyName").ToString());
Console.WriteLine(result.GetProperty("deploymentStatus").ToString());
Console.WriteLine(result.GetProperty("installedUpdate").GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("installedUpdate").GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("installedUpdate").GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("installedUpdate").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("installedUpdate").GetProperty("friendlyName").ToString());
Console.WriteLine(result.GetProperty("onLatestUpdate").ToString());
Console.WriteLine(result.GetProperty("lastDeploymentId").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("resultCode").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("extendedResultCode").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("resultDetails").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("update").GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("update").GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("update").GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("update").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("update").GetProperty("friendlyName").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("resultCode").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("extendedResultCode").ToString());
Console.WriteLine(result.GetProperty("lastInstallResult").GetProperty("stepResults")[0].GetProperty("resultDetails").ToString());
Remarques
Vous trouverez ci-dessous le schéma JSON pour la charge utile de réponse.
Corps de réponse :
Schéma pour Device
:
{
deviceId: string, # Required. Device identity.
moduleId: string, # Optional. Device module identity.
deviceClassId: string, # Required. Device class identity.
groupId: string, # Optional. Device group identity.
lastAttemptedUpdate: {
updateId: {
provider: string, # Required. Update provider.
name: string, # Required. Update name.
version: string, # Required. Update version.
}, # Required. Update identifier.
description: string, # Optional. Update description.
friendlyName: string, # Optional. Friendly update name.
}, # Optional. The update that device last attempted to install.
deploymentStatus: "Succeeded" | "InProgress" | "Canceled" | "Failed", # Optional. State of the device in its last deployment.
installedUpdate: UpdateInfo, # Optional. Currently installed update on device.
onLatestUpdate: boolean, # Required. Boolean flag indicating whether the latest update (the best compatible update for the device's device class and group) is installed on the device
lastDeploymentId: string, # Optional. The deployment identifier for the last deployment to the device
lastInstallResult: {
resultCode: number, # Required. Install result code.
extendedResultCode: number, # Required. Install extended result code
resultDetails: string, # Optional. A string containing further details about the install result
stepResults: [
{
update: UpdateInfo, # Optional. The update that this step installs if it is of reference type.
description: string, # Optional. Step description.
resultCode: number, # Required. Install result code.
extendedResultCode: number, # Required. Install extended result code
resultDetails: string, # Optional. A string containing further details about the install result
}
], # Optional. Array of step results
}, # Optional. Last install result.
}
S’applique à
Azure SDK for .NET