DigitalTwinsClient.GetDigitalTwin<T>(String, CancellationToken) Method

Definition

Gets a digital twin synchronously.

public virtual Azure.Response<T> GetDigitalTwin<T> (string digitalTwinId, System.Threading.CancellationToken cancellationToken = default);
abstract member GetDigitalTwin : string * System.Threading.CancellationToken -> Azure.Response<'T>
override this.GetDigitalTwin : string * System.Threading.CancellationToken -> Azure.Response<'T>
Public Overridable Function GetDigitalTwin(Of T) (digitalTwinId As String, Optional cancellationToken As CancellationToken = Nothing) As Response(Of T)

Type Parameters

T

The type to deserialize the digital twin to.

Parameters

digitalTwinId
System.String

The Id of the digital twin.

cancellationToken
System.Threading.CancellationToken

The cancellation token.

Returns

Response<T>

The deserialized application/json digital twin and the http response Response<T>.

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 is null.

Remarks

A strongly typed object type such as BasicDigitalTwin can be used as a generic type for T to indicate what type is used to deserialize the response value. It may also be deserialized into custom digital twin types that extend the BasicDigitalTwin with additional strongly typed properties provided that you know the definition of the retrieved digital twin prior to deserialization.

For more samples, see our repo samples.

Applies to