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.

IoTHubTokenCredentials

Creates shared access signatures based on the connection string passed to the constructor. This class is used by the protocol layer of the SDK to add authentication headers to each request.

DigitalTwinClient
DigitalTwin

Class representing a DigitalTwin.

IoTHubRegistryManager
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<Twin>) method.

Client

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

  • send cloud-to-device (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.
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).

IotHubGatewayServiceAPIs
IotHubGatewayServiceAPIsContext
BulkRegistry

Class representing a BulkRegistry.

CloudToDeviceMessages

Class representing a CloudToDeviceMessages.

ConfigurationOperations

Class representing a ConfigurationOperations.

Devices

Class representing a Devices.

Jobs

Class representing a Jobs.

Modules

Class representing a Modules.

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.

Statistics

Class representing a Statistics.

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

Interfaces

Abortable
DigitalTwinInvokeComponentCommandOptionalParams

Optional Parameters.

DigitalTwinInvokeRootLevelCommandOptionalParams

Optional Parameters.

CloudToDeviceMethod

The parameters to execute a direct method on the device.

Device

An interface representing Device.

DevicesGetDevicesOptionalParams

Optional Parameters.

DevicesUpdateTwinOptionalParams

Optional Parameters.

ExportImportDevice

An interface representing ExportImportDevice.

Module

The module identity on a device.

ModulesDeleteIdentityOptionalParams

Optional Parameters.

ModulesUpdateTwinOptionalParams

Optional Parameters.

QuerySpecification

The Json query request.

Abortable
ServiceReceiver
Transport
Abortable
TransportConfigOptions
Configuration

The configuration for Iot Hub device and module twins.

ConfigurationContent

The configuration content for devices or modules on edge devices.

ConfigurationMetrics

The configuration metrics for Iot Hub devices and modules.

Authentication
Capabilities
X509Thumbprints
DeviceMethodParams

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

AuthenticationMechanism

An interface representing AuthenticationMechanism.

BulkRegistryOperationResult

The result of the bulk registry operation.

CloudToDeviceMethodResult

Represents the Device Method Invocation Results.

ConfigurationCreateOrUpdateOptionalParams

Optional Parameters.

ConfigurationDeleteMethodOptionalParams

Optional Parameters.

ConfigurationGetConfigurationsOptionalParams

Optional Parameters.

ConfigurationQueriesTestInput

An interface representing ConfigurationQueriesTestInput.

ConfigurationQueriesTestResponse

An interface representing ConfigurationQueriesTestResponse.

DeviceCapabilities

The status of capabilities enabled on the device.

DeviceJobStatistics

The job statistics regarding execution status.

DeviceRegistryOperationError

The device registry operation error details.

DeviceRegistryOperationWarning

The device registry operation warning details.

DevicesCreateOrUpdateIdentityOptionalParams

Optional Parameters.

DevicesDeleteIdentityOptionalParams

Optional Parameters.

DevicesReplaceTwinOptionalParams

Optional Parameters.

DigitalTwinGetDigitalTwinHeaders

Defines headers for GetDigitalTwin operation.

DigitalTwinInvokeComponentCommandHeaders

Defines headers for InvokeComponentCommand operation.

DigitalTwinInvokeRootLevelCommandHeaders

Defines headers for InvokeRootLevelCommand operation.

DigitalTwinUpdateDigitalTwinHeaders

Defines headers for UpdateDigitalTwin operation.

DigitalTwinUpdateDigitalTwinOptionalParams

Optional Parameters.

IotHubGatewayServiceAPIsOptions

An interface representing IotHubGatewayServiceAPIsOptions.

JobProperties

An interface representing JobProperties.

JobRequest

An interface representing JobRequest.

JobResponse

An interface representing JobResponse.

JobsQueryScheduledJobsOptionalParams

Optional Parameters.

ModulesCreateOrUpdateIdentityOptionalParams

Optional Parameters.

ModulesReplaceTwinOptionalParams

Optional Parameters.

PropertyContainer

The desired and reported properties of the twin. The maximum depth of the object is 10.

PurgeMessageQueueResult

The result of a device message queue purge operation.

QueryGetTwinsHeaders

Defines headers for GetTwins operation.

QueryGetTwinsOptionalParams

Optional Parameters.

QueryResult

The query result.

RegistryStatistics

An interface representing RegistryStatistics.

ServiceStatistics

An interface representing ServiceStatistics.

SymmetricKey

An interface representing SymmetricKey.

TwinProperties

The desired and reported properties of the twin. The maximum depth of the object is 10.

X509Thumbprint

An interface representing X509Thumbprint.

BulkRegistryOperationResult
DeviceDescription
DeviceRegistryOperationError
JobStatus
QueryDescription
RegistryStatistics
TransportConfig
Abortable

Type Aliases

DigitalTwinInvokeComponentCommandResponse

Contains response data for the invokeComponentCommand operation.

DigitalTwinInvokeRootLevelCommandResponse

Contains response data for the invokeRootLevelCommand operation.

DigitalTwinResponse
DigitalTwinUpdateResponse
BulkRegistryUpdateRegistryResponse

Contains response data for the updateRegistry operation.

DevicesCreateOrUpdateIdentityResponse

Contains response data for the createOrUpdateIdentity operation.

DevicesGetDevicesResponse

Contains response data for the getDevices operation.

DevicesGetIdentityResponse

Contains response data for the getIdentity operation.

DevicesGetTwinResponse

Contains response data for the getTwin operation.

DevicesInvokeMethodResponse

Contains response data for the invokeMethod operation.

DevicesReplaceTwinResponse

Contains response data for the replaceTwin operation.

DevicesUpdateTwinResponse

Contains response data for the updateTwin operation.

ModulesCreateOrUpdateIdentityResponse

Contains response data for the createOrUpdateIdentity operation.

ModulesGetIdentityResponse

Contains response data for the getIdentity operation.

ModulesGetModulesOnDeviceResponse

Contains response data for the getModulesOnDevice operation.

ModulesGetTwinResponse

Contains response data for the getTwin operation.

ModulesReplaceTwinResponse

Contains response data for the replaceTwin operation.

QueryGetTwinsResponse

Contains response data for the getTwins operation.

StatisticsGetDeviceStatisticsResponse

Contains response data for the getDeviceStatistics operation.

StatisticsGetServiceStatisticsResponse

Contains response data for the getServiceStatistics operation.

TransportCtor
ConnectionState
DeviceStatus
IncomingMessageCallback
ResultWithIncomingMessage
JobCallback
JobStatus
JobStatusResponse
JobType
AuthenticationType

Defines values for AuthenticationType. Possible values include: 'sas', 'selfSigned', 'certificateAuthority', 'none'

CloudToDeviceMessagesPurgeCloudToDeviceMessageQueueResponse

Contains response data for the purgeCloudToDeviceMessageQueue operation.

ConfigurationCreateOrUpdateResponse

Contains response data for the createOrUpdate operation.

ConfigurationGetConfigurationsResponse

Contains response data for the getConfigurations operation.

ConfigurationGetResponse

Contains response data for the get operation.

ConfigurationTestQueriesResponse

Contains response data for the testQueries operation.

ConnectionState

Defines values for ConnectionState. Possible values include: 'Disconnected', 'Connected'

ConnectionState1

Defines values for ConnectionState1. Possible values include: 'Disconnected', 'Connected'

ConnectionState2

Defines values for ConnectionState2. Possible values include: 'Disconnected', 'Connected'

DigitalTwinGetDigitalTwinResponse

Contains response data for the getDigitalTwin operation.

DigitalTwinUpdateDigitalTwinResponse

Contains response data for the updateDigitalTwin operation.

ErrorCode

Defines values for ErrorCode. Possible values include: 'InvalidErrorCode', 'GenericBadRequest', 'InvalidProtocolVersion', 'DeviceInvalidResultCount', 'InvalidOperation', 'ArgumentInvalid', 'ArgumentNull', 'IotHubFormatError', 'DeviceStorageEntitySerializationError', 'BlobContainerValidationError', 'ImportWarningExistsError', 'InvalidSchemaVersion', 'DeviceDefinedMultipleTimes', 'DeserializationError', 'BulkRegistryOperationFailure', 'DefaultStorageEndpointNotConfigured', 'InvalidFileUploadCorrelationId', 'ExpiredFileUploadCorrelationId', 'InvalidStorageEndpoint', 'InvalidMessagingEndpoint', 'InvalidFileUploadCompletionStatus', 'InvalidStorageEndpointOrBlob', 'RequestCanceled', 'InvalidStorageEndpointProperty', 'EtagDoesNotMatch', 'RequestTimedOut', 'UnsupportedOperationOnReplica', 'NullMessage', 'ConnectionForcefullyClosedOnNewConnection', 'InvalidDeviceScope', 'ConnectionForcefullyClosedOnFaultInjection', 'ConnectionRejectedOnFaultInjection', 'InvalidEndpointAuthenticationType', 'ManagedIdentityNotEnabled', 'InvalidRouteTestInput', 'InvalidSourceOnRoute', 'RoutingNotEnabled', 'InvalidContentEncodingOrType', 'InvalidEndorsementKey', 'InvalidRegistrationId', 'InvalidStorageRootKey', 'InvalidEnrollmentGroupId', 'TooManyEnrollments', 'RegistrationIdDefinedMultipleTimes', 'CustomAllocationFailed', 'CustomAllocationIotHubNotSpecified', 'CustomAllocationUnauthorizedAccess', 'CannotRegisterModuleToModule', 'TenantHubRoutingNotEnabled', 'InvalidConfigurationTargetCondition', 'InvalidConfigurationContent', 'CannotModifyImmutableConfigurationContent', 'InvalidConfigurationCustomMetricsQuery', 'InvalidPnPInterfaceDefinition', 'InvalidPnPDesiredProperties', 'InvalidPnPReportedProperties', 'InvalidPnPWritableReportedProperties', 'InvalidDigitalTwinJsonPatch', 'InvalidDigitalTwinPayload', 'InvalidDigitalTwinPatch', 'InvalidDigitalTwinPatchPath', 'GenericUnauthorized', 'IotHubNotFound', 'IotHubUnauthorizedAccess', 'IotHubUnauthorized', 'ElasticPoolNotFound', 'SystemModuleModifyUnauthorizedAccess', 'GenericForbidden', 'IotHubSuspended', 'IotHubQuotaExceeded', 'JobQuotaExceeded', 'DeviceMaximumQueueDepthExceeded', 'IotHubMaxCbsTokenExceeded', 'DeviceMaximumActiveFileUploadLimitExceeded', 'DeviceMaximumQueueSizeExceeded', 'RoutingEndpointResponseForbidden', 'InvalidMessageExpiryTime', 'OperationNotAvailableInCurrentTier', 'KeyEncryptionKeyRevoked', 'DeviceModelMaxPropertiesExceeded', 'DeviceModelMaxIndexablePropertiesExceeded', 'IotDpsSuspended', 'IotDpsSuspending', 'GenericNotFound', 'DeviceNotFound', 'JobNotFound', 'QuotaMetricNotFound', 'SystemPropertyNotFound', 'AmqpAddressNotFound', 'RoutingEndpointResponseNotFound', 'CertificateNotFound', 'ElasticPoolTenantHubNotFound', 'ModuleNotFound', 'AzureTableStoreNotFound', 'IotHubFailingOver', 'FeatureNotSupported', 'DigitalTwinInterfaceNotFound', 'QueryStoreClusterNotFound', 'DeviceNotOnline', 'DeviceConnectionClosedRemotely', 'EnrollmentNotFound', 'DeviceRegistrationNotFound', 'AsyncOperationNotFound', 'EnrollmentGroupNotFound', 'DeviceRecordNotFound', 'GroupRecordNotFound', 'DeviceGroupNotFound', 'ProvisioningSettingsNotFound', 'ProvisioningRecordNotFound', 'LinkedHubNotFound', 'CertificateAuthorityNotFound', 'ConfigurationNotFound', 'GroupNotFound', 'DigitalTwinModelNotFound', 'InterfaceNameModelNotFound', 'GenericMethodNotAllowed', 'OperationNotAllowedInCurrentState', 'ImportDevicesNotSupported', 'BulkAddDevicesNotSupported', 'GenericConflict', 'DeviceAlreadyExists', 'LinkCreationConflict', 'CallbackSubscriptionConflict', 'ModelAlreadyExists', 'DeviceLocked', 'DeviceJobAlreadyExists', 'JobAlreadyExists', 'EnrollmentConflict', 'EnrollmentGroupConflict', 'RegistrationStatusConflict', 'DeviceRecordConflict', 'GroupRecordConflict', 'DeviceGroupConflict', 'ProvisioningSettingsConflict', 'ProvisioningRecordConflict', 'LinkedHubConflict', 'CertificateAuthorityConflict', 'ModuleAlreadyExistsOnDevice', 'ConfigurationAlreadyExists', 'ApplyConfigurationAlreadyInProgressOnDevice', 'DigitalTwinModelAlreadyExists', 'DigitalTwinModelExistsWithOtherModelType', 'InterfaceNameModelAlreadyExists', 'GenericPreconditionFailed', 'PreconditionFailed', 'DeviceMessageLockLost', 'JobRunPreconditionFailed', 'InflightMessagesInLink', 'GenericRequestEntityTooLarge', 'MessageTooLarge', 'TooManyDevices', 'TooManyModulesOnDevice', 'ConfigurationCountLimitExceeded', 'DigitalTwinModelCountLimitExceeded', 'InterfaceNameCompressionModelCountLimitExceeded', 'GenericUnsupportedMediaType', 'IncompatibleDataType', 'GenericTooManyRequests', 'ThrottlingException', 'ThrottleBacklogLimitExceeded', 'ThrottlingBacklogTimeout', 'ThrottlingMaxActiveJobCountExceeded', 'DeviceThrottlingLimitExceeded', 'ClientClosedRequest', 'GenericServerError', 'ServerError', 'JobCancelled', 'StatisticsRetrievalError', 'ConnectionForcefullyClosed', 'InvalidBlobState', 'BackupTimedOut', 'AzureStorageTimeout', 'GenericTimeout', 'InvalidThrottleParameter', 'EventHubLinkAlreadyClosed', 'ReliableBlobStoreError', 'RetryAttemptsExhausted', 'AzureTableStoreError', 'CheckpointStoreNotFound', 'DocumentDbInvalidReturnValue', 'ReliableDocDbStoreStoreError', 'ReliableBlobStoreTimeoutError', 'ConfigReadFailed', 'InvalidContainerReceiveLink', 'InvalidPartitionEpoch', 'RestoreTimedOut', 'StreamReservationFailure', 'SerializationError', 'UnexpectedPropertyValue', 'OrchestrationOperationFailed', 'ModelRepoEndpointError', 'ResolutionError', 'UnableToFetchCredentials', 'UnableToFetchTenantInfo', 'UnableToShareIdentity', 'UnableToExpandDiscoveryInfo', 'UnableToExpandComponentInfo', 'UnableToCompressComponentInfo', 'UnableToCompressDiscoveryInfo', 'OrphanDiscoveryDocument', 'GenericBadGateway', 'InvalidResponseWhileProxying', 'GenericServiceUnavailable', 'ServiceUnavailable', 'PartitionNotFound', 'IotHubActivationFailed', 'ServerBusy', 'IotHubRestoring', 'ReceiveLinkOpensThrottled', 'ConnectionUnavailable', 'DeviceUnavailable', 'ConfigurationNotAvailable', 'GroupNotAvailable', 'HostingServiceNotAvailable', 'GenericGatewayTimeout', 'GatewayTimeout'

ImportMode

Defines values for ImportMode. Possible values include: 'create', 'update', 'updateIfMatchETag', 'delete', 'deleteIfMatchETag', 'updateTwin', 'updateTwinIfMatchETag'

JobsCancelImportExportJobResponse

Contains response data for the cancelImportExportJob operation.

JobsCancelScheduledJobResponse

Contains response data for the cancelScheduledJob operation.

JobsCreateImportExportJobResponse

Contains response data for the createImportExportJob operation.

JobsCreateScheduledJobResponse

Contains response data for the createScheduledJob operation.

JobsGetImportExportJobResponse

Contains response data for the getImportExportJob operation.

JobsGetImportExportJobsResponse

Contains response data for the getImportExportJobs operation.

JobsGetScheduledJobResponse

Contains response data for the getScheduledJob operation.

JobsQueryScheduledJobsResponse

Contains response data for the queryScheduledJobs operation.

ModulesInvokeMethodResponse

Contains response data for the invokeMethod operation.

ModulesUpdateTwinResponse

Contains response data for the updateTwin operation.

Status

Defines values for Status. Possible values include: 'enabled', 'disabled'

Status1

Defines values for Status1. Possible values include: 'enabled', 'disabled'

Status2

Defines values for Status2. Possible values include: 'enabled', 'disabled'

Status3

Defines values for Status3. Possible values include: 'unknown', 'enqueued', 'running', 'completed', 'failed', 'cancelled', 'scheduled', 'queued'

Status4

Defines values for Status4. Possible values include: 'unknown', 'enqueued', 'running', 'completed', 'failed', 'cancelled', 'scheduled', 'queued'

StorageAuthenticationType

Defines values for StorageAuthenticationType. Possible values include: 'keyBased', 'identityBased'

Type

Defines values for Type. Possible values include: 'sas', 'selfSigned', 'certificateAuthority', 'none'

Type1

Defines values for Type1. Possible values include: 'unknown', 'export', 'import', 'backup', 'readDeviceProperties', 'writeDeviceProperties', 'updateDeviceConfiguration', 'rebootDevice', 'factoryResetDevice', 'firmwareUpdate', 'scheduleDeviceMethod', 'scheduleUpdateTwin', 'restoreFromBackup', 'failoverDataCopy'

Type2

Defines values for Type2. Possible values include: 'unknown', 'export', 'import', 'backup', 'readDeviceProperties', 'writeDeviceProperties', 'updateDeviceConfiguration', 'rebootDevice', 'factoryResetDevice', 'firmwareUpdate', 'scheduleDeviceMethod', 'scheduleUpdateTwin', 'restoreFromBackup', 'failoverDataCopy'

Type3

Defines values for Type3. Possible values include: 'unknown', 'export', 'import', 'backup', 'readDeviceProperties', 'writeDeviceProperties', 'updateDeviceConfiguration', 'rebootDevice', 'factoryResetDevice', 'firmwareUpdate', 'scheduleDeviceMethod', 'scheduleUpdateTwin', 'restoreFromBackup', 'failoverDataCopy'

Type4

Defines values for Type4. Possible values include: 'unknown', 'twin', 'deviceJob', 'jobResponse', 'raw', 'enrollment', 'enrollmentGroup', 'deviceRegistration'

WarningCode

Defines values for WarningCode. Possible values include: 'DeviceRegisteredWithoutTwin'

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>(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.

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

An object containing the different shared access signature properties extracted from the string given as a parameter

createResultWithIncomingMessage<TResult>(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

A shared access signature to be used to connect with an Azure IoT hub.