azure-iothub package

Classes

Amqp

Transport class used by the service client to connect to the Azure IoT hub using the AMQP protocol over a secure (TLS) socket. This class should not be used directly and instead be passed to one of the Client factory methods: fromConnectionString or fromSharedAccessSignature.

AmqpWs

Transport class used by the service client to connect to the Azure IoT hub using the AMQP protocol over secure websockets. This class should not be used directly and instead be passed to one of the Client factory methods: fromConnectionString or fromSharedAccessSignature.

Client

The IoT Hub service client is used to communicate with devices through an Azure IoT hub. It lets the SDK user:

  • send device-to-cloud (also known as commands) to devices: commands are queued on IoT Hub and delivered asynchronously only when the device is connected. Only 50 commands can be queued per device.
  • invoke direct methods on devices (which will work only if the device is currently connected: it's a synchronous way of communicating with the device)
  • listen for feedback messages sent by devices for previous commands.
  • listen for file upload notifications from devices. Users should create new Client instances by calling one of the factory methods, fromConnectionString or fromSharedAccessSignature, to create an IoT Hub service Client.
Device

Creates a representation of a device for use with the device identity registry APIs. This class is deprecated because the device identity registry can work directly with JSON objects containing a partial description of the device, not necessarily the full object. On top of that initially this class was shipped with a typo on the symmetricKey property name (it was pascal-cased instead of camel-cased). The SDK is keeping this class around in order not to break existing code but this will be removed in a future major version update and customers should instead use plain JSON objects.

JobClient

Provides methods to create, update, monitor and cancel long-running jobs on an IoT Hub instance, as well as query existing jobs. The Jobs API in Azure IoT Hub allows to schedule direct method calls and twin updates on multiple devices. SDK users are expected to create JobClient instances using the factory methods fromConnectionString(string) and fromSharedAccessSignature(string).

Query

Constructs a Query object that provides APIs to trigger the execution of a device query. SDK users should create queries using the createQuery(JobType, JobStatus, number) and createQuery(string, number) APIs and should not try to instantiate this class directly.

Registry

The Registry class provides access to the IoT Hub device identity service. Users of the SDK should instantiate this class with one of the factory methods: fromConnectionString or fromSharedAccessSignature. The protocol used for device identity registry operations is HTTPS.

ServiceReceiver
Twin

A Device Twin is document describing the state of a device that is stored by an Azure IoT hub and is available even if the device is offline. It is built around 3 sections:

  • Tags: key/value pairs only accessible from the service side
  • Desired Properties: updated by a service and received by the device
  • Reported Properties: updated by the device and received by the service. Note that although it is a possibility, desired and reported properties do not have to match and that the logic to sync these two collections, if necessary, is left to the user of the SDK.

For more information see Understanding Device Twins.

The recommended way to obtain a Twin for a specific device is to use the getTwin(string, HttpResponseCallback<any>) method.

Interfaces

ServiceReceiver
Transport
TransportConfigOptions
Configuration

The Configuration object represents the configuration of a single device or it can represent a deployment which can be applied as a configuration to devices based on the targetCondition.

ConfigurationContent
ConfigurationMetrics
Authentication
Capabilities
X509Thumbprints
DeviceMethodParams

Describes the parameters that are available for use with direct methods (also called device methods)

Module
BulkRegistryOperationResult
DeviceDescription
DeviceRegistryOperationError
JobStatus
QueryDescription
RegistryStatistics
TransportConfig

Type Aliases

TransportCtor
ConnectionState
DeviceStatus
IncomingMessageCallback
ResultWithIncomingMessage
JobCallback
JobStatus
JobStatusResponse
JobType
BulkRegistryOperationType
JobCallback
ResponseCallback

Functions

parse(string)

Parses a string in the format of a Shared Access Signature token and returns a <xref:SharedAccessSignature>.

createResultWithIncomingMessage(TResult, IncomingMessage)
createJobStatusResponse(any, any)
create(string, string, string, string | number)

Creates a shared access signature token to authenticate a service connection with an Azure IoT hub.

parse(string)

Parses a string in the format of a Shared Access Signature token and returns a <xref:SharedAccessSignature>.

Function Details

parse(string)

Parses a string in the format of a Shared Access Signature token and returns a <xref:SharedAccessSignature>.

function parse(source: string)

Parameters

source
string

A shared access signature string.

Returns

SharedAccessSignature

createResultWithIncomingMessage(TResult, IncomingMessage)

function createResultWithIncomingMessage<TResult>(result: TResult, message: IncomingMessage)

Parameters

result
TResult
message
IncomingMessage

Returns

createJobStatusResponse(any, any)

function createJobStatusResponse(jobStatus: any, response: any)

Parameters

jobStatus
any
response
any

Returns

create(string, string, string, string | number)

Creates a shared access signature token to authenticate a service connection with an Azure IoT hub.

function create(host: string, policy: string, key: string, expiry: string | number)

Parameters

host
string

Hostname of the Azure IoT hub.

policy
string

Name of the policy to use to connect to the Azure IoT hub (typically ServiceConnect, iothubowner etc. See Control access to your Azure IoT hub.

key
string

Symmetric key to use to create shared access signature tokens.

expiry
string | number

Expiry time for the token that will be created.

Returns

SharedAccessSignature

parse(string)

Parses a string in the format of a Shared Access Signature token and returns a <xref:SharedAccessSignature>.

function parse(source: string)

Parameters

source
string

A shared access signature string.

Returns

SharedAccessSignature