I have some devices that sends their data to my Azure IoT Hub. For now, a Stream analytics job processes the data, but I would also like to "forward" the data stream to an external Mosquitto server. How can I do that? Can I set up the IoT Hub to function as a MQTT Bridge?
Thanks in advance for help! (Sorry, I'm a little new to this...)
One option: You can use Azure Functions to process the incoming data and forward it to your Mosquito server.
Related
im new to mqtt and currently trying to setup a mqtt protocol to send data from a gateway devices to azure iot hub. The problem i facing was I couldn't figure out which way that I can received and store data on IoT Hub when i published my data on mqtt broker. The textbook way is to subscribe the mqtt broker using Azure IOT Hub but how should I do it?
Assuming I am doing testing using a laptop
Read data stored in json file -> published to topic "data/device1" -> Data stored in Azure IoT Hub
I tried reading the Azure IoT HUB MQTT Connections but it doesnt work out for me. PLease Help
By default Azure IoT Hub makes incoming telemetry messages available on its Event Hub-compatible endpoint: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-read-builtin It does not matter over which protocol (MQTT, AMQP or HTTPS) you sent in the messages to IoT Hub - they all will land in that endpoint.
From there you can read the information using HTTPS or AMQP. I would recommend to use the Event Hub SDK or use a stream processing service like Azure Stream Analytics or Spark Streaming, which supports Event Hub directly.
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.
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?
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.
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.
I am working on a simple dashboard for showing IoT data in a browser.
So far, I was using the Paho MQTT client library and a public MQTT broker to receive data. However, I'd like to use the Azure IoT Hub from now on.
The data I'm sending is just simple temperature and humidity values.
I already found out that I can't connect to the IoT Hub via MQTT. So my question is:
Is there a possibility to connect (eg. using javascript) directly to IoT Hub and read the data?
If not, what's my best option?
I thought about saving the messages to an SQL Database and reading from that, but that seems quite complicated for what should be a simple IoT use case (showing real-time data)
Thank you in advance!
You can connect to IoT Hub via MQTT. Please take a look at this documentation for detail. We also have a Node.js SDK for connecting to IoT Hub if you don't want to deal with MQTT directly. I know you are working on your own dashboard, but have you looked at Azure IoT Solutions Accelerator? It's completely open source and you can modify it as you want.
I want to send SIM808 GPS data to the Azure IoT hub using MQTT.
As mentioned in docs of azure, I have used the same parameters.
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#using-the-mqtt-protocol-directly
But it doesn't work. Did not published.
Can we connect to Azure MQTT using Username and password without attaching certificate? if not
How to create the certificate?
How to send SIM808 data to the Azure IoT hub using MQTT?
Suggest me a way to do it with an example.
Thanks!!!
Yes, you can do it. You can use tokens.
As a simplest alternative you may also use flespi telematics hub to reach same goal. Your device can send via HTTP or MQTT messages to flespi channel. And flespi will stream processed information to MS Azure and/or AWS in their specific protocols.
I'm looking for a way to scale a Azure Function properly but I have a problem.
I have a set of IoT devices that send data to Azure by HTTP (For this there is a set of Azure Functions that scale automatically)
But now there is a new IoT device that sends the data via TCP/IP Persistent connections and as far as I know this ins't supported by Azure Functions.
Anyone has some ideia on how to implement this?
One option I thought was to have a VM treating the TCP connections and sending the data to a queue so that a function can pull from the queue in a scalable manner.
Thanks in advance, cheers.
If your device only communicates via a persistent TCP/IP connection, then you'll need to implement an IoT Gateway. An IoT Gateway basically an app that either runs on-premises or in the cloud, it communicates with 1 or more IoT devices, then the Gateway can connect to and communicate with a service like Azure IoT Hub. From there, you can get your events sent up to Azure IoT Hub, then process those events in the cloud by using something like Azure Stream Analytics to send then to Event Hubs, or Service Bus Queue, as example. Then once in a Queue you can write an Azure Function to be triggered to handle those events as they come int.
There is no way to open a persistent TCP/IP connection to an Azure Function. Azure Functions are Serverless compute, and are built to be Event-Driven in nature and short running. It is recommended that an Azure Function runs for for a maximum duration of less than 5 minutes per execution.
I think your best bet is decoupling from the device protocols; functions can bind to Event Hubs, and you can put your proxies in containers (pretty easy to host and scale those on App Svcs or AKS).
This way the brittle part (the proxies) are easy to test.
Something like fanout.io might work depending on the protocol. If it's MQTT, going Azure IoT Hub may make sense.