DeviceManagementClient.GetHealthOfDevices(String, RequestContext) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Get list of device health.
public virtual Azure.Pageable<BinaryData> GetHealthOfDevices (string filter, Azure.RequestContext context = default);
abstract member GetHealthOfDevices : string * Azure.RequestContext -> Azure.Pageable<BinaryData>
override this.GetHealthOfDevices : string * Azure.RequestContext -> Azure.Pageable<BinaryData>
Public Overridable Function GetHealthOfDevices (filter As String, Optional context As RequestContext = Nothing) As Pageable(Of BinaryData)
Parameters
- filter
- String
Restricts the set of devices for which device health is returned. You can filter on status, device id and module id.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The Pageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.
Exceptions
filter
is null.
Service returned a non-success status code.
Examples
This sample shows how to call GetHealthOfDevices with required parameters and parse the result.
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.GetHealthOfDevices("<filter>"))
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("deviceId").ToString());
Console.WriteLine(result.GetProperty("moduleId").ToString());
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("digitalTwinModelId").ToString());
Console.WriteLine(result.GetProperty("healthChecks")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("healthChecks")[0].GetProperty("result").ToString());
}
Remarks
Below is the JSON schema for one item in the pageable response.
Response Body:
Schema for DeviceHealthListValue
:
{
deviceId: string, # Required. Device id
moduleId: string, # Optional. Module id
state: "healthy" | "unhealthy", # Required. Aggregate device health state
digitalTwinModelId: string, # Optional. Digital twin model Id
healthChecks: [
{
name: string, # Optional. Health check name
result: "success" | "userError", # Optional. Health check result
}
], # Required. Array of health checks and their results
}
Applies to
Azure SDK for .NET