Table of Contents

Class AssetClient

Namespace
Azure.Iot.Operations.Connector
Assembly
Azure.Iot.Operations.Connector.dll

A client for updating the status of an asset and for forwarding received events and/or sampled datasets.

public class AssetClient : IDisposable
Inheritance
AssetClient
Implements
Inherited Members

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

ForwardReceivedEventAsync(string, AssetEvent, byte[], Dictionary<string, string>?, string?, CancellationToken)

Push a received event payload to the configured destinations.

public Task ForwardReceivedEventAsync(string eventGroupName, AssetEvent assetEvent, byte[] serializedPayload, Dictionary<string, string>? userData = null, string? protocolSpecificIdentifier = null, CancellationToken cancellationToken = default)

Parameters

eventGroupName string

The name of the event group that this event belongs to.

assetEvent AssetEvent

The event.

serializedPayload byte[]

The payload to push to the configured destinations.

userData Dictionary<string, string>

Optional headers to include in the telemetry. Only applicable for datasets with a destination of the MQTT broker.

protocolSpecificIdentifier string

Optional protocol specific identifier.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

ForwardSampledDatasetAsync(AssetDataset, byte[], Dictionary<string, string>?, string?, CancellationToken)

Push a sampled dataset to the configured destinations.

public Task ForwardSampledDatasetAsync(AssetDataset dataset, byte[] serializedPayload, Dictionary<string, string>? userData = null, string? protocolSpecificIdentifier = null, CancellationToken cancellationToken = default)

Parameters

dataset AssetDataset

The dataset that was sampled.

serializedPayload byte[]

The payload to push to the configured destinations.

userData Dictionary<string, string>

Optional headers to include in the telemetry. Only applicable for datasets with a destination of the MQTT broker.

protocolSpecificIdentifier string

Optional protocol specific identifier.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

GetAndUpdateAssetStatusAsync(Func<AssetStatus, AssetStatus?>, bool, TimeSpan?, CancellationToken)

Get the current status of this asset and then optionally update it.

public Task<AssetStatus> GetAndUpdateAssetStatusAsync(Func<AssetStatus, AssetStatus?> handler, bool onlyIfChanged = false, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)

Parameters

handler Func<AssetStatus, AssetStatus>

The function that determines the new asset status when given the current asset status.

onlyIfChanged bool

Only send the status update if the new status is different from the current status. If the only difference between the current and new status is a 'LastTransitionTime' field, then the statuses will be considered identical.

commandTimeout TimeSpan?

The timeout for each of the 'get' and 'update' commands.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<AssetStatus>

The latest asset status after this operation.

Remarks

If after retrieving the current status, you don't want to send any updates, handler should return null. If this happens, this function will return the latest asset status without trying to update it.

This method uses a semaphore to ensure that this same client doesn't accidentally update the asset status while another thread is in the middle of updating the same asset. This ensures that the current device status provided in handler stays accurate while any updating occurs.

GetRegisteredDatasetMessageSchema(string)

public MessageSchemaReference? GetRegisteredDatasetMessageSchema(string datasetName)

Parameters

datasetName string

Returns

MessageSchemaReference

GetRegisteredEventMessageSchema(string, string)

public MessageSchemaReference? GetRegisteredEventMessageSchema(string eventGroupName, string eventName)

Parameters

eventGroupName string
eventName string

Returns

MessageSchemaReference

ReportDatasetRuntimeHealthAsync(DatasetsRuntimeHealthEvent, TimeSpan?, CancellationToken)

Report the health of a given asset's dataset.

public Task ReportDatasetRuntimeHealthAsync(DatasetsRuntimeHealthEvent runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

runtimeHealth DatasetsRuntimeHealthEvent

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

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

Report the health of a given asset's datasets.

public Task ReportDatasetRuntimeHealthAsync(List<DatasetsRuntimeHealthEvent> runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

runtimeHealth List<DatasetsRuntimeHealthEvent>

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

ReportEventRuntimeHealthAsync(EventsRuntimeHealthEvent, TimeSpan?, CancellationToken)

Report the health of a given asset's event.

public Task ReportEventRuntimeHealthAsync(EventsRuntimeHealthEvent runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

runtimeHealth EventsRuntimeHealthEvent

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

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

Report the health of a given asset's events.

public Task ReportEventRuntimeHealthAsync(List<EventsRuntimeHealthEvent> runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

runtimeHealth List<EventsRuntimeHealthEvent>

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

ReportManagementActionRuntimeHealthAsync(ManagementActionsRuntimeHealthEvent, TimeSpan?, CancellationToken)

Report the health of a given management action.

public Task ReportManagementActionRuntimeHealthAsync(ManagementActionsRuntimeHealthEvent runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

runtimeHealth ManagementActionsRuntimeHealthEvent

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

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

Report the health of some given management actions.

public Task ReportManagementActionRuntimeHealthAsync(List<ManagementActionsRuntimeHealthEvent> runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

runtimeHealth List<ManagementActionsRuntimeHealthEvent>

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

ReportStreamRuntimeHealthAsync(StreamsRuntimeHealthEvent, TimeSpan?, CancellationToken)

Report the health of a given asset's stream.

public Task ReportStreamRuntimeHealthAsync(StreamsRuntimeHealthEvent runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

runtimeHealth StreamsRuntimeHealthEvent

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

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

Report the health of a given asset's streams.

public Task ReportStreamRuntimeHealthAsync(List<StreamsRuntimeHealthEvent> runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

runtimeHealth List<StreamsRuntimeHealthEvent>

The health status to report.

telemetryTimeout TimeSpan?

Optional message expiry time for the telemetry.

cancellationToken CancellationToken

Cancellation token.

Returns

Task