DigitalTwinsClient.PublishTelemetry Method

Definition

Publishes telemetry from a digital twin synchronously. The result is then consumed by one or many destination endpoints (subscribers) defined under DigitalTwinsEventRoute. These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed.

public virtual Azure.Response PublishTelemetry (string digitalTwinId, string messageId, string payload, DateTimeOffset? timestamp = default, System.Threading.CancellationToken cancellationToken = default);
abstract member PublishTelemetry : string * string * string * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> Azure.Response
override this.PublishTelemetry : string * string * string * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> Azure.Response
Public Overridable Function PublishTelemetry (digitalTwinId As String, messageId As String, payload As String, Optional timestamp As Nullable(Of DateTimeOffset) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response

Parameters

digitalTwinId
System.String

The Id of the digital twin.

messageId
System.String

A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. Defaults to a random GUID if argument is null.

payload
System.String

The application/json telemetry payload to be sent.

timestamp
System.Nullable<System.DateTimeOffset>

An RFC 3339 timestamp that identifies the time the telemetry was measured. It defaults to the current date/time UTC.

cancellationToken
System.Threading.CancellationToken

The cancellation token.

Returns

Response

The http response Response.

Exceptions

The exception that captures the errors from the service. Check the ErrorCode and Status properties for more details.

System.ArgumentNullException

The exception is thrown when digitalTwinId or payload is null.

Remarks

For more samples, see our repo samples.

Applies to

See also