I have a device connected to Azure IOT Hub. I have messages coming to the hub for every 20 Sec. Now for every incoming message I have some business logic to execute. I have attached event hub and stream analytics to the IOT Hub to fetch the latest record but again I am only capable of pushing it to BLOB Storage. How can I get the latest message/events as a json out of the system.
I found out that Azure Functions is a go. But I am finding samples from C#, I am looking for JavaScript/Java.
Any Help is appreciated. Thanks
You can attach an Azure Function to your Event Hub with event hub trigger. You can find examples of such function in
Azure Event Hubs bindings for Azure Functions
Processing data from IoT Hub with Azure Functions
Related
There is a kafka connect connector for iothub. This is available from the confluent website (https://www.confluent.io/hub/microsoft/kafka-connect-iothub). However, the iothub connector in kafka connect is archived (see https://github.com/Azure/toketi-kafka-connect-iothub) and the last commit dates from 2018-03-19.
In the meantime the plugin does not work with the current version and needs to be updated.
Is there an alternative repo available. Did microsoft stop supporting this? Is there a plan?
The Kafka connector project for communicating with IoT devices is indeed retired.
If only one-way is desired, Event Hubs does have a Kafka compatibility layer and IoT Hub message routing can be used to take advantage of that scenario.
You can reach out via Azure Support Request if you are looking for other alternatives and we can share our roadmap under NDA. When you open the Azure Ticket, reference this SO thread.
I am trying to send data to Azure IoT Hub from Apache NiFi. Using Publish MQTT processor I am trying to publish data. Is this a right approach to send a data from NiFi to IoT Hub? Is there any other way?
You can use the MQTT protocol directly (as a device) to send and receive data from Azure IoT Hub - like described here: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#using-the-mqtt-protocol-directly-as-a-device
As long as you can connect over TLS/SSL you should be fine.
Per link! here, Azure Functions Service Bus trigger lets you listen on Azure Service Bus. We are currently using mostly AWS for our cloud services. And we are working with vendor who has real time notifications using Azure service bus. I would like to know if there is anyway to connect to service bus using lambda. Anytime there is a new message on the bus, we would like our AWS lambda to invoke and take it from there.
It's not possible. However you can use Azure functions (Azure serverless offering) triggered by Azure Service bus to consume the messages.
If you really want cross vendor trigger then you need to consume azure service bus message, convert the message into http payload and trigger AWS lambda with Http payload that has message contents.
Cloudwatch Event Rule: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/Create-CloudWatch-Events-Rule.html
You specify your event source -- a supported Service and an action/API call and the targets and setting up the required IAM setting(Lambda permission etc. if you create from IaC tools like terraform..) And you are good to go!
Then as long as Cloudwatch event rule is up, all the events that falls into the rule you specify will trigger your lambda.
Event rule can also be used a "cron schedule" for lambda, which I have been using. I did encounter some delay very rarely tho.
Update: to make it as real time as possible, you would need to make modification to your vendor's Azure account to enable some message pushing to your AWS endpoint(an API gateway), which I assume is a NO. Other than that, a AWS self contained solution is to set up a cloudwatch event rule to pull your vendor's Azure HTTP endpoint every 1 minutes and store the stuff in your own SQS queues.
For the past few days I've been struggling to analyze the traffic that an IoT Edge device generates when transmitting data to IoT Hub.
The metrics in the hub fall in line perfectly with my expectation of around 120KB per hour, which is roughly the size of the messages I`m sending with the module client.
But when I monitor the network traffic of the device the result is 20MB sent and around 10 MB received, for a total of over 30MB per hour for AMQPS which is a huge difference.
Has anyone encountered this and is there some way to find out the reason for the discrepancy in the data.
IoT Hub provides several metrics to give you an overview of the health of your hub and the total number of connected devices. In your mentions, the metric only included d2c messages. The communication between the client and service includes not only d2c messeage protocol but also other protocols.
Azure IoT Edge bridges the traffic to IoT Hub over AMQP 1.0. It plugs in components for specialized processing such as custom authentication, message transformations, compression/decompression, or encryption/decryption of traffic between the devices and IoT Hub.
The Azure IoT protocol gateway and MQTT/AMQP implementation are provided in an open-source software project.You can refer to Microsoft.Azure.Devices.Edge.Hub.Amqp.
This ended up being a bug in IoT Edge runtime and was resolved with version 1.0.2 more info can be found on GitHub
I have a custom Endpoint + Route setup based on TwinChangeEvent in Azure IoT Hub. I'm routing the events to a Service Bus Queue (tried topic also). I'm using Java Service Bus SDK (azure-servicebus-1.1.0.jar) to pull messages off of the queue.
However, I keep getting a NullPointerException in
com.microsoft.azure.servicebusMessageConverter on line 124
"brokeredMessage.setMessageId(amqpMessage.getMessageId().toString());"
The messageId property seems to be getting lost during the routing.
Any way to get around this?
I don't see anywhere in the Azure IoT Device SDK where I would need to set this once I've processed the original message from IoT Hub indicating the property changed.
Thanks