Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Edge HMI

AzureIoTHubOpen

  • Last UpdatedOct 29, 2026
  • 2 minute read

AzureIoTHubOpen creates a new Azure IoT Hub connection. See Notes for more information.

Function

Group

Execution

String Exp.

Windows

Windows Embedded

IoT View

Thin Clients

Mobile Access

AzureIoTHubOpen

Internet of Things

Asynchronous

No

Supported

Not supported

Not supported

Supported

Supported

Syntax

AzureIoTHubOpen(strAlias, strConfig)

strAlias

The name you want to give to the Azure IoT Hub connection that you are creating. This is the name that other functions will reference in order to use the connection.

strConfig

The configuration parameters for the Azure IoT Hubconnection. These parameter are listed in a single string enclosed in quotes with the format [parameter]=value separated by commas. The variables are:

Parameter Name

Description

Gateway

IP address and port of the IoT Hub connection, using the format IP_Address:Port_Number

Connection

Connection string to IoT Hub. This value can be obtained from the IoT Hub portal. This is a semicolon-separated list of values including HostName, DeviceId, and SharedAccessKey.

Transport

The transport type, which has the following options: AMPQ, AMPQ_TCP_ONLY, AMQP_WEBSOCKET_ONLY, MQTT, MQTT_TCP_ONLY, MQTT_WEBSOCKET_ONLY, and HTTP1.

USEPROXY

Optional. Use value True if a web proxy is required to connect to IoT Hub host.

PROXYADDRESS

Optional. If using a web proxy, use the value of the address. Add a port number after a colon if appropriate.

PROXYUSECREDENTIALS

Optional. If the web proxy requires authentication, use value True.

PROXYUSER

Optional. Username if the web proxy requires authentication.

PROXYPASSWORD

Optional. Password if the web proxy require authentication.

Return value

If successful, this function returns 0 (zero).

If unsuccessful, this function returns one of the following negative integer values:

Value

Description

-300

Invalid alias detected by server

-301

Invalid connection parameter

-302

Invalid message parameter

-303

Invalid type parameter

-304

Invalid property parameter

-305

Invalid message ID parameter

-306

Connection has not been defined

-307

Conflicting alias

-308

Open connection error

-309

Invalid command

-310

Communication error

-311

Invalid parameter index

Notes

Messages are kept in the Gateway ("alive" in the IoT Hub queue) for up to 10 minutes before they are deleted from the queue. (The settings for messages are currently configured in the IoT Hub settings.) The Gateway has a limit of 100 messages per connection; older messages (in terms of creation time) will be deleted to make room for newer messages.

Examples

As used in a Math worksheet:

Tag Name

Expression

nErr

AzureIoTHubOpen ("Test","Connection=HostName=myhost.azure-devices.net;DeviceId=MyDevice;SharedAccessKey= fVxJl+ea7eh4nYp64Yub+E1n52uatVG0uyTuLqZIyKA=)

nErr

AzureIoTHubOpen ("Test","Gateway=127.0.0.1:3997,Transport=MQTT,Connection=HostName=myhost.azure-devices.net;DeviceId=MyDevice;SharedAccessKey= fVxJl+ea7eh4nYp64Yub+E1n52uatVG0uyTuLqZIyKA=)

In This Topic