Table of Contents

Class AzureDeviceRegistryClient

Namespace
Azure.Iot.Operations.Services.AssetAndDeviceRegistry
Assembly
Azure.Iot.Operations.Services.dll
public class AzureDeviceRegistryClient : IAzureDeviceRegistryClient, IAsyncDisposable
Inheritance
AzureDeviceRegistryClient
Implements
Inherited Members

Constructors

AzureDeviceRegistryClient(ApplicationContext, IMqttPubSubClient, IRetryPolicy?)

Construct an ADR service client.

public AzureDeviceRegistryClient(ApplicationContext applicationContext, IMqttPubSubClient mqttClient, IRetryPolicy? retryPolicy = null)

Parameters

applicationContext ApplicationContext

The shared context for this application.

mqttClient IMqttPubSubClient

The MQTT client to communicate with the ADR service with.

retryPolicy IRetryPolicy

The retry policy to apply to all operations. By default, ExponentialBackoffRetryPolicy will be used if none is provided. NoRetryPolicy can be provided if no retry is desired.

Methods

CreateOrUpdateDiscoveredAssetAsync(string, string, CreateOrUpdateDiscoveredAssetRequest, TimeSpan?, CancellationToken)

Creates or updates a discovered asset.

public Task<CreateOrUpdateDiscoveredAssetResponsePayload> CreateOrUpdateDiscoveredAssetAsync(string deviceName, string inboundEndpointName, CreateOrUpdateDiscoveredAssetRequest request, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

request CreateOrUpdateDiscoveredAssetRequest

The request containing discovered asset creation parameters.

commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<CreateOrUpdateDiscoveredAssetResponsePayload>

A task that represents the asynchronous operation, containing the response for the created discovered asset.

CreateOrUpdateDiscoveredDeviceAsync(CreateOrUpdateDiscoveredDeviceRequestSchema, string, TimeSpan?, CancellationToken)

Creates or updates a discovered device.

public Task<CreateOrUpdateDiscoveredDeviceResponsePayload> CreateOrUpdateDiscoveredDeviceAsync(CreateOrUpdateDiscoveredDeviceRequestSchema request, string inboundEndpointType, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

request CreateOrUpdateDiscoveredDeviceRequestSchema

The request containing discovered device endpoint profile creation parameters.

inboundEndpointType string
commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<CreateOrUpdateDiscoveredDeviceResponsePayload>

A task that represents the asynchronous operation, containing the response for the created discovered device endpoint profile.

DisposeAsync()

Asynchronously dispose this object, but not the underlying clients.

public ValueTask DisposeAsync()

Returns

ValueTask

DisposeAsync(bool)

Asynchronously dispose of this client and optionally dispose the underlying clients

public ValueTask DisposeAsync(bool disposing)

Parameters

disposing bool

If true, this client will also dispose the underlying clients.

Returns

ValueTask

DisposeAsync(bool, CancellationToken)

Asynchronously dispose of this client and optionally dispose the underlying clients

public ValueTask DisposeAsync(bool disposing, CancellationToken cancellationToken)

Parameters

disposing bool

If true, this client will also dispose the underlying clients.

cancellationToken CancellationToken

Cancellation token

Returns

ValueTask

DisposeAsync(CancellationToken)

Asynchronously dispose this object, but not the underlying clients.

public ValueTask DisposeAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

ValueTask

DisposeAsyncCore(bool, CancellationToken)

protected virtual ValueTask DisposeAsyncCore(bool disposing, CancellationToken cancellationToken)

Parameters

disposing bool
cancellationToken CancellationToken

Returns

ValueTask

GetAssetAsync(string, string, string, TimeSpan?, CancellationToken)

Retrieves details of a specific asset.

public Task<Asset> GetAssetAsync(string deviceName, string inboundEndpointName, string assetName, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

assetName string
commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<Asset>

A task that represents the asynchronous operation, containing the asset details.

GetAssetStatusAsync(string, string, string, TimeSpan?, CancellationToken)

Retrieves the status of a specific asset.

public Task<AssetStatus> GetAssetStatusAsync(string deviceName, string inboundEndpointName, string assetName, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

assetName string

The name of the asset.

commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<AssetStatus>

A task that represents the asynchronous operation, containing the asset status.

GetDeviceAsync(string, string, TimeSpan?, CancellationToken)

Retrieves details of a specific device.

public Task<Device> GetDeviceAsync(string deviceName, string inboundEndpointName, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<Device>

A task that represents the asynchronous operation, containing the device details.

GetDeviceStatusAsync(string, string, TimeSpan?, CancellationToken)

Retrieves the status of a specific device.

public Task<DeviceStatus> GetDeviceStatusAsync(string deviceName, string inboundEndpointName, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<DeviceStatus>

A task that represents the asynchronous operation, containing the device status.

ReportDatasetRuntimeHealthAsync(string, string, string, List<DatasetsRuntimeHealthEvent>, TimeSpan?, CancellationToken)

Report the health of a given asset dataset.

public Task ReportDatasetRuntimeHealthAsync(string deviceName, string inboundEndpointName, string assetName, List<DatasetsRuntimeHealthEvent> datasetsRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the endpoint.

assetName string

The name of the asset this dataset belongs to.

datasetsRuntimeHealth List<DatasetsRuntimeHealthEvent>

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

This package contains the AssetRuntimeHealthReporter class which can more smartly report this same information with de-duplication + background reporting. Connectors should generally use that class rather than directly call this method.

ReportDeviceEndpointRuntimeHealthAsync(string, string, RuntimeHealth, TimeSpan?, CancellationToken)

Report the health of a given device endpoint.

public Task ReportDeviceEndpointRuntimeHealthAsync(string deviceName, string inboundEndpointName, RuntimeHealth deviceEndpointRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the endpoint.

deviceEndpointRuntimeHealth RuntimeHealth

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

This package contains the DeviceEndpointRuntimeHealthReporter class which can more smartly report this same information with de-duplication + background reporting. Connectors should generally use that class rather than directly call this method.

ReportEventRuntimeHealthAsync(string, string, string, List<EventsRuntimeHealthEvent>, TimeSpan?, CancellationToken)

Report the health of a given asset event.

public Task ReportEventRuntimeHealthAsync(string deviceName, string inboundEndpointName, string assetName, List<EventsRuntimeHealthEvent> eventsRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the endpoint.

assetName string

The name of the asset this dataset belongs to.

eventsRuntimeHealth List<EventsRuntimeHealthEvent>

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

This package contains the AssetRuntimeHealthReporter class which can more smartly report this same information with de-duplication + background reporting. Connectors should generally use that class rather than directly call this method.

ReportManagementActionRuntimeHealthAsync(string, string, string, List<ManagementActionsRuntimeHealthEvent>, TimeSpan?, CancellationToken)

Report the health of a given management action.

public Task ReportManagementActionRuntimeHealthAsync(string deviceName, string inboundEndpointName, string assetName, List<ManagementActionsRuntimeHealthEvent> managementActionsRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the endpoint.

assetName string

The name of the asset this dataset belongs to.

managementActionsRuntimeHealth List<ManagementActionsRuntimeHealthEvent>

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

This package contains the AssetRuntimeHealthReporter class which can more smartly report this same information with de-duplication + background reporting. Connectors should generally use that class rather than directly call this method.

ReportStreamRuntimeHealthAsync(string, string, string, List<StreamsRuntimeHealthEvent>, TimeSpan?, CancellationToken)

Report the health of a given asset stream.

public Task ReportStreamRuntimeHealthAsync(string deviceName, string inboundEndpointName, string assetName, List<StreamsRuntimeHealthEvent> streamsRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the endpoint.

assetName string

The name of the asset this dataset belongs to.

streamsRuntimeHealth List<StreamsRuntimeHealthEvent>

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

This package contains the AssetRuntimeHealthReporter class which can more smartly report this same information with de-duplication + background reporting. Connectors should generally use that class rather than directly call this method.

RunWithRetryAsync<TResult>(Func<Task<TResult>>, CancellationToken)

public Task<TResult> RunWithRetryAsync<TResult>(Func<Task<TResult>> taskFunc, CancellationToken cancellationToken)

Parameters

taskFunc Func<Task<TResult>>
cancellationToken CancellationToken

Returns

Task<TResult>

Type Parameters

TResult

SetNotificationPreferenceForAssetUpdatesAsync(string, string, string, NotificationPreference, TimeSpan?, CancellationToken)

Observe or unobserve updates for a specific asset.

public Task<SetNotificationPreferenceForAssetUpdatesResponsePayload> SetNotificationPreferenceForAssetUpdatesAsync(string deviceName, string inboundEndpointName, string assetName, NotificationPreference notificationPreference, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

assetName string

The name of the asset.

notificationPreference NotificationPreference
commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<SetNotificationPreferenceForAssetUpdatesResponsePayload>

A task that represents the asynchronous operation, containing the notification response.

SetNotificationPreferenceForDeviceUpdatesAsync(string, string, NotificationPreference, TimeSpan?, CancellationToken)

Observe or unobserve updates for a specific device endpoint.

public Task<SetNotificationPreferenceForDeviceUpdatesResponsePayload> SetNotificationPreferenceForDeviceUpdatesAsync(string deviceName, string inboundEndpointName, NotificationPreference notificationPreference, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

notificationPreference NotificationPreference
commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<SetNotificationPreferenceForDeviceUpdatesResponsePayload>

A task that represents the asynchronous operation, containing the notification response.

StopAsync(CancellationToken)

Make this client unsubscribe from any topics that it subscribed to.

public Task StopAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task

UpdateAssetStatusAsync(string, string, UpdateAssetStatusRequest, TimeSpan?, CancellationToken)

Updates the status of a specific asset.

public Task<AssetStatus> UpdateAssetStatusAsync(string deviceName, string inboundEndpointName, UpdateAssetStatusRequest request, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

request UpdateAssetStatusRequest

The request containing asset status update parameters.

commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<AssetStatus>

A task that represents the asynchronous operation, containing the updated asset details.

UpdateDeviceStatusAsync(string, string, DeviceStatus, TimeSpan?, CancellationToken)

Updates the status of a specific device.

public Task<DeviceStatus> UpdateDeviceStatusAsync(string deviceName, string inboundEndpointName, DeviceStatus status, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint.

status DeviceStatus

The new status of the device.

commandTimeout TimeSpan?

Optional timeout for the command.

cancellationToken CancellationToken

Optional cancellation token.

Returns

Task<DeviceStatus>

A task that represents the asynchronous operation, containing the updated device details.

Events

OnReceiveAssetUpdateEventTelemetry

Event triggered when an asset update telemetry event is received. NOTE: This event starts triggering after the call to SetNotificationPreferenceForAssetUpdatesAsync(string, string, string, NotificationPreference, TimeSpan?, CancellationToken).

public event Func<string, Asset, Task>? OnReceiveAssetUpdateEventTelemetry

Event Type

Func<string, Asset, Task>

OnReceiveDeviceUpdateEventTelemetry

Event triggered when a device update telemetry event is received. NOTE: This event starts triggering after the call to SetNotificationPreferenceForDeviceUpdatesAsync(string, string, NotificationPreference, TimeSpan?, CancellationToken).

public event Func<string, string, Device, Task>? OnReceiveDeviceUpdateEventTelemetry

Event Type

Func<string, string, Device, Task>