3

I have an Azure IoTHub with thousands of devices registered. These devices communicate through a Telco provider who sends messages through an Azure Storage Queue. This Storage Queue triggers an Azure Function which needs to parse the messages and Send an Event to the IoTHub as below. enter image description here

Currently, we use the Azure IoTHub SDK to create a DeviceClient for each payload and we send the event. Because the DeviceClient represents a device in the IoTHub and is carrying the context of the source of the events, we are having to recreate a device client for each event. This quickly exceeds the threshold of the number of Connections allowed on Azure Functions.

We have tried using the IoTHub Output bindings for Azure Functions, but could not get to work and I do not think it would work because we need to make sure that the events get to the IoTHub with the right context (messages are sent by the right device).

What's the right way to solve this? Can the connections to the IoTHub be reused? Should we abandon Azure Function in favour of something else?

Has AlTaiar
  • 4,052
  • 2
  • 36
  • 37
  • the simple way is to use a connection-less protocol to the Azure IoT Hub such as https, see the https://learn.microsoft.com/en-us/rest/api/iothub/device/senddeviceevent, on the other side, based on your business requirements, the IoT Edge device can be used as a gateway, see more details https://learn.microsoft.com/en-us/azure/iot-edge/iot-edge-as-gateway – Roman Kiss Oct 05 '19 at 16:31

2 Answers2

1

I assume that Telco is some kind of custom device management solution(vendor lock solution), that can also communicate with the device and receive the device telemetry, and eventually forward it to the specified endpoint, correct?

If I may ask and if my assumption is correct, why do you need to deliver the events to IoT Hub, if you are not managing Telco devices through IoT Hub(the arrows on your diagram are only in one direction)?

Using the IoT Hub just as a message broker for essentially cloud-to-cloud communication is not beneficial if that is the only purpose. Also conceptually what you described is cloud-to-cloud communication, and IoT Hub is intended to be used for devices.

Here is what I would do. Setup the API Management(or http triggered Azure Function) as a front door for Telco and pass the messages to the Event Hub. You can choose here to pass request body for example where your telemetry data is - I assume again.

Keep the IoT Hub, and setup the routing to previously created Event Hub.

Now, in case you have devices that are not vendor locked and that can talk directly to IoT Hub, messages will be re-routed to Event Hub. Also Telco device messages will be routed to exactly the same Event Hub.

Now you can have for example Azure Stream Analytics that can analyze data stream just from the Event Hub, and for both, Telco devices and potentially non-Telco devices.

kgalic
  • 2,441
  • 1
  • 9
  • 21
0

After trying a few things, I ended up moving away from using the SDK for pushing messages to IoT Hub. This is because the SDK uses AMQP, and creating a DeviceClient for each payload is not viable. We switched to using HTTPS instead to push the messages to IoT Hub and using HttpClientFactory, we are able to do connection pooling. I thought I would put this here in case someone has the same issue.

Here is an example of the Http request to send message to IoT Hub

Host: https://<iothubname>.azure-devices.net/devices/<deviceId>/messages/events?api-version=2018-06-30

Authorization: SharedAccessSignature sr=<iothubname>.azure-devices.net&sig=abc123;12344iweoippweruea=iothubowner&se=1570574220

Body: <normal Interval or alarms payloads> // example {"deviceid": "abc", "hello": "world"}

Lastly, thanks @kgalic for the answer but your suggestion would not work. This is not pure B2B integration. Our implementation have to allow for both devices connecting directly to the IoT Hub and devices connecting through the Telco. This is why every device needs to have its own identity and digital twin.

Has AlTaiar
  • 4,052
  • 2
  • 36
  • 37