DeviceClient DeviceClient DeviceClient Class

Definition

Contains methods that a device can use to send messages to and receive from the service.

public sealed class DeviceClient
type DeviceClient = class
Public NotInheritable Class DeviceClient
Inheritance
DeviceClientDeviceClientDeviceClient

Fields

DefaultOperationTimeoutInMilliseconds DefaultOperationTimeoutInMilliseconds DefaultOperationTimeoutInMilliseconds

Default operation timeout.

Properties

DiagnosticSamplingPercentage DiagnosticSamplingPercentage DiagnosticSamplingPercentage

Diagnostic sampling percentage value, [0-100];
0 means no message will carry on diag info

OperationTimeoutInMilliseconds OperationTimeoutInMilliseconds OperationTimeoutInMilliseconds

Stores the timeout used in the operation retries.

ProductInfo ProductInfo ProductInfo

Stores custom product information that will be appended to the user agent string that is sent to IoT Hub.

RetryPolicy RetryPolicy RetryPolicy

Stores the retry strategy used in the operation retries.

Methods

AbandonAsync(Message) AbandonAsync(Message) AbandonAsync(Message)

Puts a received message back onto the device queue

AbandonAsync(String) AbandonAsync(String) AbandonAsync(String)

Puts a received message back onto the device queue

AbandonAsync(Message, CancellationToken) AbandonAsync(Message, CancellationToken) AbandonAsync(Message, CancellationToken)

Puts a received message back onto the device queue

AbandonAsync(String, CancellationToken) AbandonAsync(String, CancellationToken) AbandonAsync(String, CancellationToken)

Puts a received message back onto the device queue

CloseAsync() CloseAsync() CloseAsync()

Close the DeviceClient instance

CloseAsync(CancellationToken) CloseAsync(CancellationToken) CloseAsync(CancellationToken)

Close the DeviceClient instance

CompleteAsync(Message) CompleteAsync(Message) CompleteAsync(Message)

Deletes a received message from the device queue

CompleteAsync(String) CompleteAsync(String) CompleteAsync(String)

Deletes a received message from the device queue

CompleteAsync(Message, CancellationToken) CompleteAsync(Message, CancellationToken) CompleteAsync(Message, CancellationToken)

Deletes a received message from the device queue

CompleteAsync(String, CancellationToken) CompleteAsync(String, CancellationToken) CompleteAsync(String, CancellationToken)

Deletes a received message from the device queue

Create(String, String, IAuthenticationMethod, TransportType) Create(String, String, IAuthenticationMethod, TransportType) Create(String, String, IAuthenticationMethod, TransportType)

Create a DeviceClient from individual parameters

Create(String, String, IAuthenticationMethod, ITransportSettings[]) Create(String, String, IAuthenticationMethod, ITransportSettings[]) Create(String, String, IAuthenticationMethod, ITransportSettings[])

Create a DeviceClient from individual parameters

Create(String, String, IAuthenticationMethod) Create(String, String, IAuthenticationMethod) Create(String, String, IAuthenticationMethod)

Create an Amqp DeviceClient from individual parameters

Create(String, IAuthenticationMethod, ITransportSettings[]) Create(String, IAuthenticationMethod, ITransportSettings[]) Create(String, IAuthenticationMethod, ITransportSettings[])

Create a DeviceClient from individual parameters

Create(String, IAuthenticationMethod) Create(String, IAuthenticationMethod) Create(String, IAuthenticationMethod)

Create an Amqp DeviceClient from individual parameters

Create(String, IAuthenticationMethod, TransportType) Create(String, IAuthenticationMethod, TransportType) Create(String, IAuthenticationMethod, TransportType)

Create a DeviceClient from individual parameters

CreateFromConnectionString(String) CreateFromConnectionString(String) CreateFromConnectionString(String)

Create a DeviceClient using Amqp transport from the specified connection string

CreateFromConnectionString(String, ITransportSettings[]) CreateFromConnectionString(String, ITransportSettings[]) CreateFromConnectionString(String, ITransportSettings[])

Create DeviceClient from the specified connection string using a prioritized list of transports

CreateFromConnectionString(String, TransportType) CreateFromConnectionString(String, TransportType) CreateFromConnectionString(String, TransportType)

Create DeviceClient from the specified connection string using the specified transport type

CreateFromConnectionString(String, String) CreateFromConnectionString(String, String) CreateFromConnectionString(String, String)

Create a DeviceClient using Amqp transport from the specified connection string

CreateFromConnectionString(String, String, ITransportSettings[]) CreateFromConnectionString(String, String, ITransportSettings[]) CreateFromConnectionString(String, String, ITransportSettings[])

Create DeviceClient from the specified connection string using the prioritized list of transports

CreateFromConnectionString(String, String, TransportType) CreateFromConnectionString(String, String, TransportType) CreateFromConnectionString(String, String, TransportType)

Create DeviceClient from the specified connection string using the specified transport type

Dispose() Dispose() Dispose()

Releases the unmanaged resources used by the DeviceClient and optionally disposes of the managed resources.

GetTwinAsync() GetTwinAsync() GetTwinAsync()

Retrieve a device twin object for the current device.

GetTwinAsync(CancellationToken) GetTwinAsync(CancellationToken) GetTwinAsync(CancellationToken)

Retrieve a device twin object for the current device.

OpenAsync(CancellationToken) OpenAsync(CancellationToken) OpenAsync(CancellationToken)

Explicitly open the DeviceClient instance.

A cancellation token to cancel the operation.Thrown when the operation has been canceled.
OpenAsync() OpenAsync() OpenAsync()

Explicitly open the DeviceClient instance.

ReceiveAsync() ReceiveAsync() ReceiveAsync()

Receive a message from the device queue using the default timeout.

ReceiveAsync(CancellationToken) ReceiveAsync(CancellationToken) ReceiveAsync(CancellationToken)

Receive a message from the device queue using the default timeout.

ReceiveAsync(TimeSpan) ReceiveAsync(TimeSpan) ReceiveAsync(TimeSpan)

Receive a message from the device queue with the specified timeout

RejectAsync(Message) RejectAsync(Message) RejectAsync(Message)

Deletes a received message from the device queue and indicates to the server that the message could not be processed.

RejectAsync(String) RejectAsync(String) RejectAsync(String)

Deletes a received message from the device queue and indicates to the server that the message could not be processed.

RejectAsync(Message, CancellationToken) RejectAsync(Message, CancellationToken) RejectAsync(Message, CancellationToken)

Deletes a received message from the device queue and indicates to the server that the message could not be processed.

RejectAsync(String, CancellationToken) RejectAsync(String, CancellationToken) RejectAsync(String, CancellationToken)

Deletes a received message from the device queue and indicates to the server that the message could not be processed.

SendEventAsync(Message) SendEventAsync(Message) SendEventAsync(Message)

Sends an event to device hub

SendEventAsync(Message, CancellationToken) SendEventAsync(Message, CancellationToken) SendEventAsync(Message, CancellationToken)

Sends an event to device hub

SendEventBatchAsync(IEnumerable<Message>, CancellationToken) SendEventBatchAsync(IEnumerable<Message>, CancellationToken) SendEventBatchAsync(IEnumerable<Message>, CancellationToken)

Sends a batch of events to device hub

SendEventBatchAsync(IEnumerable<Message>) SendEventBatchAsync(IEnumerable<Message>) SendEventBatchAsync(IEnumerable<Message>)

Sends a batch of events to device hub

SetConnectionStatusChangesHandler(ConnectionStatusChangesHandler) SetConnectionStatusChangesHandler(ConnectionStatusChangesHandler) SetConnectionStatusChangesHandler(ConnectionStatusChangesHandler)

Registers a new delegate for the connection status changed callback. If a delegate is already associated, it will be replaced with the new delegate.

The name of the method to associate with the delegate.
SetDesiredPropertyUpdateCallback(DesiredPropertyUpdateCallback, Object) SetDesiredPropertyUpdateCallback(DesiredPropertyUpdateCallback, Object) SetDesiredPropertyUpdateCallback(DesiredPropertyUpdateCallback, Object)

Set a callback that will be called whenever the client receives a state update (desired or reported) from the service. This has the side-effect of subscribing to the PATCH topic on the service.

SetDesiredPropertyUpdateCallbackAsync(DesiredPropertyUpdateCallback, Object) SetDesiredPropertyUpdateCallbackAsync(DesiredPropertyUpdateCallback, Object) SetDesiredPropertyUpdateCallbackAsync(DesiredPropertyUpdateCallback, Object)

Set a callback that will be called whenever the client receives a state update (desired or reported) from the service. This has the side-effect of subscribing to the PATCH topic on the service.

SetDesiredPropertyUpdateCallbackAsync(DesiredPropertyUpdateCallback, Object, CancellationToken) SetDesiredPropertyUpdateCallbackAsync(DesiredPropertyUpdateCallback, Object, CancellationToken) SetDesiredPropertyUpdateCallbackAsync(DesiredPropertyUpdateCallback, Object, CancellationToken)

Set a callback that will be called whenever the client receives a state update (desired or reported) from the service. This has the side-effect of subscribing to the PATCH topic on the service.

SetMethodDefaultHandlerAsync(MethodCallback, Object) SetMethodDefaultHandlerAsync(MethodCallback, Object) SetMethodDefaultHandlerAsync(MethodCallback, Object)

Registers a new delegate that is called for a method that doesn't have a delegate registered for its name. If a default delegate is already registered it will replace with the new delegate.

SetMethodDefaultHandlerAsync(MethodCallback, Object, CancellationToken) SetMethodDefaultHandlerAsync(MethodCallback, Object, CancellationToken) SetMethodDefaultHandlerAsync(MethodCallback, Object, CancellationToken)

Registers a new delegate that is called for a method that doesn't have a delegate registered for its name. If a default delegate is already registered it will replace with the new delegate.

SetMethodHandler(String, MethodCallback, Object) SetMethodHandler(String, MethodCallback, Object) SetMethodHandler(String, MethodCallback, Object)

Registers a new delegate for the named method. If a delegate is already associated with the named method, it will be replaced with the new delegate.

The name of the method to associate with the delegate.The delegate to be used when a method with the given name is called by the cloud service.generic parameter to be interpreted by the client code.
SetMethodHandlerAsync(String, MethodCallback, Object) SetMethodHandlerAsync(String, MethodCallback, Object) SetMethodHandlerAsync(String, MethodCallback, Object)

Registers a new delegate for the named method. If a delegate is already associated with the named method, it will be replaced with the new delegate.

The name of the method to associate with the delegate.The delegate to be used when a method with the given name is called by the cloud service.generic parameter to be interpreted by the client code.
SetMethodHandlerAsync(String, MethodCallback, Object, CancellationToken) SetMethodHandlerAsync(String, MethodCallback, Object, CancellationToken) SetMethodHandlerAsync(String, MethodCallback, Object, CancellationToken)

Registers a new delegate for the named method. If a delegate is already associated with the named method, it will be replaced with the new delegate.

The name of the method to associate with the delegate.The delegate to be used when a method with the given name is called by the cloud service.generic parameter to be interpreted by the client code.A cancellation token to cancel the operation.Thrown when the operation has been canceled.
SetRetryPolicy(IRetryPolicy) SetRetryPolicy(IRetryPolicy) SetRetryPolicy(IRetryPolicy)

Sets the retry policy used in the operation retries. The change will take effect after any in-progress operations.

UpdateReportedPropertiesAsync(TwinCollection) UpdateReportedPropertiesAsync(TwinCollection) UpdateReportedPropertiesAsync(TwinCollection)

Push reported property changes up to the service.

UpdateReportedPropertiesAsync(TwinCollection, CancellationToken) UpdateReportedPropertiesAsync(TwinCollection, CancellationToken) UpdateReportedPropertiesAsync(TwinCollection, CancellationToken)

Push reported property changes up to the service.

UploadToBlobAsync(String, Stream) UploadToBlobAsync(String, Stream) UploadToBlobAsync(String, Stream)

Uploads a stream to a block blob in a storage account associated with the IoTHub for that device. If the blob already exists, it will be overwritten.

UploadToBlobAsync(String, Stream, CancellationToken) UploadToBlobAsync(String, Stream, CancellationToken) UploadToBlobAsync(String, Stream, CancellationToken)

Uploads a stream to a block blob in a storage account associated with the IoTHub for that device. If the blob already exists, it will be overwritten.

Applies to