I am sending sensor data to azure table storage. I want to send an email if a value in a column is less than a particular value.
please find the attached images
-If a value in GPIOPin column is less than 7 then an email alert has to be sent.
Could someone please guide how to proceed? I have tried with Logic apps but I am not understanding how to provide a condition there.
AFAIK, Logic Apps do not support Triggers for Azure Table Storage for now. You could add your feedback here. Based on your scenario, you need to choose the Schedule - recurrence Connector for retrieving records from your table storage and process your logic Periodically. Since there is no trigger for create/update operation, you need to add a new column (e.g. status) which indicates that whether it has been checked by your logic app flow. Here is my designer for this scenario, you could refer to it as follows:
Note:
For the (Azure Table Storage) Get entities action, you could specific the filter query to status eq false
under the advanced options for retrieving the records which have not been checked before.
For the condition block, if there has multiple rules within a single condition block, you need to use @and()
or @or()
in code-view. Here is a feedback, you could refer to here.
If true for the condition block, you could send the email, after successfully send the email you need to use the Merge Entity action of Azure Table storage to update the status column of the current record as follows:
If false for the condition block, you also need to update the status column for the current record of table storage.
Additionally, logic apps support the trigger when a item is created in SQL Server. If possible, you could change your data store for a simpler way. Moreover, there is no triggers binding for Table Storage in Azure Functions. You could leverage timer trigger, Storage table bindings, SendGrid bindings in Azure Functions for achieving your purpose.
The major purpose of logic apps is connecting various inputs/services with various outputs: you can just as easily send an email as post a twitter message. If that is really what you need, by all means, use a logic app.
I think you're better off using an azure function. A function can be automatically invoked (triggered) on a row change, so you can send the mail at the moment the value less than seven is inserted. For details see https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table
There is a 'AzureTableStorage' connector in preview which you can use to create your own workflow with conditions.
If you're sending your sensor data to table storage via IoT hub, consider using Streaming Analytics with two outputs defined. One output can be the table storage and the other output an Azure function with Streaming Analytics for its input binding and SendGrid for its output binding. The Streaming Analytics job would select all records for the table storage output, but only those meeting the GPIOIn < 7 condition to the Azure function output.