Share via


TwinsClient.GetAsync Method

Definition

Overloads

GetAsync(String, CancellationToken)

Gets a device's twin from IoT hub.

GetAsync(String, String, CancellationToken)

Gets a module's twin from IoT hub.

GetAsync(String, CancellationToken)

Gets a device's twin from IoT hub.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin> GetAsync (string deviceId, System.Threading.CancellationToken cancellationToken = default);
abstract member GetAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin>
override this.GetAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin>
Public Overridable Function GetAsync (deviceId As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ClientTwin)

Parameters

deviceId
String

The device Id.

cancellationToken
CancellationToken

Task cancellation token.

Returns

The device twin.

Exceptions

When the provided deviceId is null.

If the deviceId is empty or white space.

If IoT hub responded to the request with a non-successful status code. For example, if the provided request was throttled, IotHubServiceException with ThrottlingException is thrown. For a complete list of possible error cases, see IotHubServiceErrorCode.

If the HTTP request fails due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

If the provided cancellationToken has requested cancellation.

Applies to

GetAsync(String, String, CancellationToken)

Gets a module's twin from IoT hub.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin> GetAsync (string deviceId, string moduleId, System.Threading.CancellationToken cancellationToken = default);
abstract member GetAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin>
override this.GetAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.ClientTwin>
Public Overridable Function GetAsync (deviceId As String, moduleId As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ClientTwin)

Parameters

deviceId
String

The device Id.

moduleId
String

The module Id.

cancellationToken
CancellationToken

Task cancellation token.

Returns

The module twin.

Exceptions

When the provided deviceId or moduleId is null.

If the deviceId or moduleId is empty or white space.

If IoT hub responded to the request with a non-successful status code. For example, if the provided request was throttled, IotHubServiceException with ThrottlingException is thrown. For a complete list of possible error cases, see IotHubServiceErrorCode.

If the HTTP request fails due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

If the provided cancellationToken has requested cancellation.

Applies to