Publish data to Microsoft Azure IoT Hub
The following section describes step-by-step how to use the configurator to sample data from a TwinCAT 3 PLC runtime and publish it to Microsoft Azure IoT Hub using a JSON data format.
Configure ADS gate, channel and symbols
Follow the step-by-step instructions to create an ADS gate and a subscriber channel and add symbols to the channel’s configuration.
- The topology view is activated.
- 1. Right-click the canvas and select Add Gate (ADS).
- 2. Select the new gate and configure ADS specific settings in the properties window (AmsNetId, AdsPort, …).
- 3. Right-click the new gate and select Add Channel (Subscriber).
- 4. Select the new channel and set “SamplingMode” to “Cyclic”. Leave all other fields on their default settings.
- 5. Open the Target Browser.
- 6. Navigate to the ADS device and add some symbols to the configuration by dragging them to the subscriber channel.
- An ADS gate and a subscriber channel have been created. Symbols have been added to the channel.
![]() | AMS Net ID Make sure that the AMS Net ID, which has been configured on the ADS gate, matches the ADS device that you selected with the target browser. |
Configure Azure IoT Hub gate and channel
Follow the step-by-step instructions to create an Azure IoT Hub gate and a Publisher channel.
- The topology view is activated.
- 1. Right-click on the empty area and select Add Gate (IoT Hub).
- 2. Select the new gate and configure the IoT Hub-related settings in the properties window (device name, primary key, CA certificate).
- 3. Right-click on the new gate and select Add Channel (Publisher).
- 4. Select the new channel and set "SamplingMode" to "OnChange" and "Formatter" to "Simple JSON". Leave the default settings for all other fields.
- An Azure IoT Hub gate and a Publisher channel were created.
![]() | CA certificate A CA certificate must be specified when establishing a connection with Microsoft Azure IoT Hub. At the time of writing this documentation article, Microsoft migrated all Azure IoT Hub instances to a new root CA (Baltimore Cyber Trust Root CA -> DigiCert Global Root G2). Therefore, please always consult the Microsoft documentation as well to find out the currently valid root CA. In most cases, the corresponding public key of the respective root CA can be extracted from the Microsoft Windows certificate console (Start > Run > mmc.exe, then add the "Certificates" snap-in). See also screenshot below for comparison. |

Create mapping
Follow the step-by-step instructions to create a mapping between source and destination symbols. Note that a mapping can only be created between channels that have different roles (e.g. between a subscriber and a publisher channel and vice versa).
Drag-and-drop - Channel:
While holding the CTRL key, drag the subscriber channel to the publisher channel.
The configurator automatically creates new symbols on the publisher channel and a mapping between the source and destination symbol.
Drag-and-drop – Symbol:
While holding the CTRL key, drag a symbol from the subscriber channel to either an existing symbol on the publisher channel or to the publisher channel itself.
The configurator creates a link between source and destination symbol or, if the symbol has been dragged to a channel object, creates the destination symbol automatically
Activate configuration
Follow the step-by-step instructions to activate the currently opened configuration.
- 1. Select the target system via the toolbar.
- 2. Click the Activate Configuration button.
- A dialog opens asking if you want to switch the target TC3 IoT Data Agent into run mode.
- 3. Confirm the dialog with Yes if you want to switch the mode. Otherwise, choose No.
- The configuration is activated.
The resulting configuration looks like this:
