Subscribing to device/module to cloud messages in Azure IoTHub

Hello,

Is there any guidance/tutorial on subscribing to device/module to cloud messages in Azure IoTHub?

I went through the Getting Started guide (https://www.losant.com/blog/getting-started-with-azure-iot-and-losant) but that one shows how to monitor cloud to device messages with the Losant side behaving as a device.

Instead, I want to be able to monitor messages coming from a device to Azure IoTHub and visualize them in Losant. I tried changing the subscribed topic to devices/{device id}/messages/events/ but I am not seeing any data in Losant.

Hi @Prince_Samuel,

Welcome to the Losant Forums! In that post you linked to, there is a section called “Receiving A Message From Azure”. That as the first part of this. If you set everything up like the tutorial, the topic is:

/devices/losant/messages/devicebound/#

Now, to actually save the data within Losant ( or we call it reporting state) you need to use the Device State Node in your Workflow.

More on state:

Please don’t hesitate to ask more questions. Happy to help further :slight_smile:

Thanks! That’s not what I want :slight_smile:

/devices/losant/messages/devicebound/# is for monitoring cloud to device messages.

I have my hardware device sending data to Azure IoTHub. I want to visualize this data in Losant. I.e monitor device to cloud messages.

@Prince_Samuel,

My apologies. Sorry about that, I read your message too fast.

So, I did some research to see if you could actually subscribe to the devices/{device_id}/messages/events/ topic. It looks like that’s not the case. Based on this:

https://social.msdn.microsoft.com/Forums/en-US/a0a1bcd4-6f58-4658-adee-0b863e19bdfe/how-do-i-subscribe-to-and-receive-mqtt-messages?forum=azureiothub

Generally, you can get data to Losant via MQTT or HTTP (via webhooks). This is where my Azure knowledge gets muddy and I’ll have to do some research. Here is where I am now:

It looks like you may be able to route device to cloud messages to other places. By default, they route the messages here:

But, it looks like that’s the AMQP. Losant doesn’t support that.

I may need some time to dig in more. But, one approach that I know will work is to trigger an Azure Function from IoTHub that can send the data to Losant via an HTTP Webhook.

Hopefully, this is enough to point you in the right direction. I’m going to ask internally so see if there are some other approaches. I’ll be sure to follow up if a better route is presented.

1 Like

Hi @anaptfox

Was wondering if you had a bit more guidance on the Azure Function that could send data to Losant via HTTP Webhook?

I am slightly familiar with Azure Functions and am starting to read up on the Webhooks available in Losant. Azure Functions seem to be an extremely dynamic bucket that you could throw just about any type of code in to run?

@Kyle_Stokes, yes!

As information is getting set to IoT Hub, you can trigger a Function that will then make an HTTP request to forward that data to Losant. I’m actually typing up an example on how to do this now. Stay Tuned!

@Prince_Samuel , @Kyle_Stokes,

We just published this article that I think would be useful to you two: