Azure IoT-Hub and Microsoft Flow

Would you require more information on this topic?

Please request a free consultation appointment with us.

Azure IoT-Hub and Microsoft Flow

What is Azure IoT-Hub?

Microsoft's Azure IoT Hub is a cloud service for the secure management of Internet of Things (IoT) devices. Sending messages or telemetry data to the Azure IoT-Hub is achieved through the use of appropriate software. However, this can also be done with the help of Microsoft Flow.

Microsoft's Azure IoT-Hub is the scalable transport layer for connecting, monitoring and managing Internet of Things devices. There are countless examples and solutions to send (test) data to the IoT-Hub. Nearly all of these approaches have the disadvantage that you have to deal with, corresponding to single-board computers and/or the programming of simulators, which can be very time-consuming.

The task is to find a simple method to send data (messages) to the Azure IoT-Hub without much effort.

The creation of an IoT-Hub and related devices in Microsoft Azure is not discussed in this article. For more information, visit:

What does the concrete solution look like?

The sending of events and messages with HTTP via REST (Representational State Transfer - programming interface/programming paradigm) seems to be a favorable procedure here. Using the POST method (for transmission), a HTTP request can be sent to the IoT hub in order to transport the data from the body. The structure of the URI to be used is as follows:


IoT-HubID is the unique name of the used Azure IoT-Hub and DeviceID is the unique device ID. The body of the call contains the possible value pairs according to the following scheme:

Body-Structure for the value pairs

Body-Structure Body-Example

"Attribut_1": "Messwert_1",
"Attribut_n": "Messwert_n"

"Ort": "Oldenburg",
"Temperatur": "12,0"

For security reasons, a SAS token must also be sent using the header of the HTTP request. The device is then authenticated and can send data to the IoT-Hub. The generation of the SAS token can be generated with the help of a few lines of code or better, with the Azure Device Explorer.

The IoT-Hub Connection String must simply be entered in the Device Explorer twin. This can be found in the Azure Portal under the desired IoT-Hub in the "Settings / Guidelines for shared access" area:

IoT-Hub Richtlinie

Fig. 1: IoT-Hub – Shared access policies

The "Connection string - primary key" is entered in the Device Explorer as follows:

Fig. 2: Device Explorer Twin – Connection string - Primary key

In the Device Explorer under the tab "Management" you can find all devices registered in the IoT-Hub after a [Refresh].

Fig. 3: Device Explorer Twin – Device Management

The [SAS Token...] button can then be used to generate the SAS token by specifying the validity period (TTL Days). We only need the marked part of the generated text. This can simply be copied to the clipboard for further use.

Fig. 4: Device Explorer – SAS Token Form

For the HTTP request, we now have the URI with IoT HubID and DeviceID, the header with the generated SAS token, and the body with the corresponding measurement data.

How to send messages using Microsoft Flow?

Microsoft Flow can be used to assemble all parts and send data to the IoT hub. With Microsoft Flow it is possible to create and manage automated workflows. Further information about Microsoft Flow can be found at the following link:

We only need two connectors here. One flow button connector and one HTTP connector. The advantage of this connector combination is that the flow app can also be used on the mobile phone to record and send measured values.

The overall configuration for our flow example "AzureIoTHubTest" thus looks like this:


Fig. 5: Microsoft Flow – “AzureIoTHubTest”

The Button Connector is configured as follows:

Schaltflächen Connector

Fig. 6: Button Connector

As an example, two fields ("Status" and "Temperature") are added, where "Status" contains a list of possible options and "Temperature" is a free input field. By default, the flow button also provides the location, user, timestamp, etc.

In the next connector everything is put together:

HTTP Connector

Fig. 7: HTTP Connector

POST is selected as the method for the HTTP request. The URI, specified as described above, the generated SAS token is entered in the header and the body is assigned the required value pairs.

If the flow is now started via mobile phone or the MS-Flow-Dashboard, the successful workflow run can be tracked in the course of the process.

Erfolgreich ausgeführter Flow

Fig. 8: Successfully executed flow

The values of the button passed in the body can also be seen here.

On the Azure IoT Hub overview page, the reception of the message is displayed:

Prüfung der Nutzung im IoT-Hub Dashboard Fig. 9: Testing the usage in the IoT Hub Dashboard


Sending messages to the Azure IoT hub is easy with Microsoft Flow. No matter if you want to send test data to the IoT-Hub quickly or if you want to collect real data via mobile phone in the field. The combination of Azure IoT-Hub, Device-Explorer and Microsoft Flow allows a fast and comfortable realization of these applications.

If IoT devices are to send data to the IoT hub, corresponding code snippets must be used for the authentication and transmission of telemetry data. Here, however, a corresponding but manageable development effort is necessary. This would, however, also regulate bidirectional communication between IoT devices and the solution backend. At the end the data has to be analyzed. Also here Microsoft Azure offers corresponding services such as Stream Analytics and Machine Learning.

If you don't want to orchestrate these services yourself, you are well advised to use the pre-configured solutions from the Azure IoT Solution Accelerators. There are solutions for remote monitoring, maintenance solutions, solutions for the connected factory and various device simulations. The advantage of these preconfigured solutions is that the used Azure services can be adapted and extended by the user as if the services were added manually in Azure.

Another IoT service in Azure is IoT-Central. IoT-Central is a fully managed SaaS (Software as a Service) solution that makes it easy to link, manage and monitor IoT resources. Setting up this service is very simple, so the effort is limited.

Overall, Microsoft Azure IoT provides a comprehensive collection of services and solutions for creating end-to-end IoT applications. From fully hosted and managed to customizable services that can be tailored to meet the specific needs of each user's industry.


No available comments yet

Do you have any questions?

About Us

SWMS Systemtechnik Ingenieurgesellschaft mbH is a consulting and technology company in the field of software conception and development and virtual product development.

Working Hours

Monday - Friday : 8:00 - 16:00
Weekends / Holidays : Closed


If you have any questions , feel free to contact us at any time by mail ( or during business hours by telephone in Oldenburg at +49 (0) 441 960 21 0.


Have a look around our different categories for interesting, inspiring articles


Would you like to receive interesting subject-related content by e-mail? Then subscribe to our newsletter now.
Copyright © 1996 SWMS Systemtechnik Ingenieurgesellschaft mbH. | Impressum, Datenschutz, AGBs