I am developing a Azure IOTHUB use case.
Multiple Load cells are sending continuously (every 1/2 sec) sending data to IOTHUB. (DeviceID, weight).
SQL Table with User Data .
I want to make a system that that sends an email notification on certain weight to the device owner.
What is the right approach to achieve that.
I have seen Logic apps is an option but how to implement it with multiple user account and devices.
I would use IoT Hub routing to push the messages that meet the weight criteria to a service bus queue. From there you can use an Azure Function with a Service Bus Trigger. I assume the user account information (e-mail address?) is available via a query in the SQL table. Azure Functions have a SendGrid binding that you'd then use to send out the e-mail.
Note that routing IoT Hub directly to a function is on the backlog.
Basically, there are two solutions for your scenario, when each device has own criteria on the weight:
The device twin desired property contains a weight value used for publishing a non-telemetry alert message by a real device to the Azure IoT Hub. This alert message can be routed in the Azure IoT Hub Routes to the custom endpoint the same way like is described in Jim's answer (ServiceBus->AzureFuction->SendGrid)
The second solution is more complex, generic, very flexible and it doesn't require any special coding on the device side or device twin. It's based on the standard telemetry stream pipeline with Azure Stream Analytics (ASA) job for analyzing events and generating a notification message for output to the Azure Function with SendGrid. The ASA job used a reference data (user data, weight, etc.) from the blob file generated and refreshed by SQL Database.
The following screen snippet shows this solution:
I would like to present one another approach which I think is correct too (I tested this flow):
Data is sent to the Azure IoT Hub from device
Azure Stream Analytics filters this data basing on weight and deviceID
Once data is analyzed there is a call to the Azure Function which triggers Azure Logic App with data collected from the Stream Analytics
Azure Logic App receives data (HTTP trigger) from Azure Function App
Then Logic App uses "Get row" action step to get user data from SQL Database
Last step is up to you - you can use either "SendGrid - send e-mail" action or integrate Logic App with Outlook or even Office365, Gmail and other services.
Here are the links to the documentation:
Connect to SQL Server or Azure SQL Database from Azure Logic Apps
Send emails and manage mailing lists in SendGrid by using Azure Logic Apps
Related
I'm making a comparison between different Cloud vendors for IoT solutions.
I'm now on Azure IoT Hub, which will ingest data from IoT devices (we want only to send from devices to cloud, say through MQTT, and not receive anything back). My aim is to pass these data to an Azure Function, execute some computation, and save them in some DB (e.g.CosmosDB). Here my doubts:
Which MQTT messages Do I have to consider for the billing? (only those with telemetry or which others?)
I saw that there is the possibility of going from Hub IoT to Azure Function with a built-in endpoint. Is it free? I'm afraid of some hidden costs, like those of Event Hubs or the built-in endpoint.
The sending of data from IoT Hub to Azure Function is considered as a normal "cloud-to-device" messages (and consequently they're billed), or are they free? For example IoT Hub ingest 10 messages (<4KB) and forward them to Functions. Do I pay them as 10 messages or 20 messages?
Thanks in advance for your help.
Which MQTT messages - You have to consider the below list of messages for Azure IoTHub Billing, they are
Device to Cloud
Cloud to Device
Method execution
Jobs
Detailed break up of billing information by each operation
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-pricing#charges-per-operation
Nothing free in the cloud :)
Data read from IoTHub to any other service attracts the regular data transfer cost. Refer to the below link
https://azure.microsoft.com/en-in/pricing/details/bandwidth/
All the pricing information detailed here https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-pricing is specific to Azure IoTHub for D2C & C2D. Any data egress from IoTHub to other Azure Services is as per the regular data transfer charges.
https://azure.microsoft.com/en-in/pricing/details/bandwidth/
I am exploring the Azure IoT central rest APIs to create a custom Angular client. Is this possible or does it have any limitations? IoT Central is attractive due to its pricing. Specifically, I found that retrieving multiple telemetry values isn't possible as per the following documentation page. Which means you have to send individual "get" requests to fetch multiple telemetry.
Azure IoT Central (get telemetry value)
Is there a possibility to register a call back and receive regular updates of the values like in event hubs? Basically I want to develop a custom client facing app with the IoT Central Pricing. Is it possible?
It is possible, to receive regular updates on telemetry you can use continuous data export. You can export to Service Bus, Event Hubs and Blob Storage. See the documentation here on how to set that up. You can receive those events in any JavaScript application.
Please be aware that continuous data export will give you updates from all devices. If you need to filter them out you will need to build something to filter that out. One example I have built in the past is a .NET Core application that listens to the messages and sends that to the different clients over SignalR.
Setup till now:
I have created spaces. At the top level I have the IOT hub resource. In two of spaces, I have attached devices to it along with the sensors. I have created a Matcher for the Temperature sensor along with the UDF that is similar to the documentation. I have also assigned permissions to UDF. To send data to IOT hub, I have also fetched the device connection string for the dotnet sample
List of issues I am facing:
When I try to run the dotnet sample, I can see that it is able to reach the UDF(checked it via debugging), but in the UDF, it is not able to access the telemetry variable as given in documentation . The error it shows is :
Unexpected exception occurred while processing user-defined function. Please contact support and provide the correlation ID for the request.
I have created an endpoint to send Raw Telemetry to Event Hub. But I want to send the processed data from UDF to cosmos db. Is it possible? If yes then how?
Thanks for the question and reaching out...for #2 you could do this by doing a notify method in your UDF. You can setup egress to other endpoints such as Event Hub, Event Grid or Service Bus via the endpoint dispatcher. You would setup endpoint via the /endpoint API and then in your UDF you could specify what you want to send out and which changes. For details on the events and endpoints you can see here: https://learn.microsoft.com/en-us/azure/digital-twins/how-to-egress-endpoints
Here's also here is a link to learn more about this connecting Digital Twins over to Logic Apps: https://learn.microsoft.com/en-us/azure/digital-twins/tutorial-facilities-events which would have a similar pattern to sending data over to Cosmos DB.
As for the first one I am not sure if you are still seeing this. Which region? Do you have a correlation ID that you can pass along? Also if you turn on logs and look in Azure Monitor are there details there?
In my python application, if any bad/good event happens, I want to send the event details as notification message to user's email addresses or phone #s that have been subscribed to this application. So I am looking for publisher-subscriber model azure cloud
Looks like multiple Azure services achieving similar goal but having a thin line of differences. Event hubs and notification hubs seems promising. So my question is as follows:
Can email ID/phone # be subscribed to Azure event hub and receive the message being sent/produced to Azure event hub?
If not event hub, what is the correct option? Can I achieve it with Service bus or Notification hub?
In AWS, there is a service called SNS (Simple Notification Service) where one can subscribe email/phone number and opt for receiving event messages about that application. I am looking for equivalent to that in Azure.
You can use the Azure Logic Apps / Azure Functions with Event Hubs to achieve this easily.
Using logic apps you can do like simple as below image.
Logic Apps has many in-build connectors for most all Azure Services, you can use Event-hubs,Service bus,SQL etc.,
You can find all the list of available connectors here
Update 1
Once you connected the Event-Hubs to send an Email connector, you will automatically get all the available source data from event-hubs to email task. See below
You can achieve this by using Azure Application Insights. With this, you will be able to monitor your application and receive alerts during application unavailabillity, failures or even during performance issue.
Check this https://learn.microsoft.com/en-us/azure/application-insights/app-insights-tutorial-alert
I'm creating an IoT solution. On my web app i want to have a table on the dashboard that updates alert events in realtime.
I currently have an API, written in NodeJS that receives the JSON and invokes sockets.io to update the table. This solution seems a bit clunky.
I'm wondering is there a more seamless way to do this, similar to how the different components within azure link together.
I've looked into Azure Queues and having nodeJS subscribe and consume from the queue but as far as I could find there's no way to persist a queue connection from NodeJS and I would have had to continually poll.
I've looked into Power BI as well but I need to be able to completely change and modify every aspect of the design too.
The following is what I have so far:
Devices send data to IoT Hub. This is then processed by an azure stream analytics job and if a certain criteria is hit it sends the message to a documentDB for storage, and also to a service bus queue. I have a logic app which is triggered by a message arriving on the service bus queue and then POSTs the data to my API.