0

I have a IOT Hub which receive messages (avro format) from connected device. I want to configure the alerts (under IOT Hub Monitoring section) based on the specific values in the message however it seems alerting don't have provision to configure rule based on the date being sent by device.

Any pointers on this? is this possible or any alternate option?

Thanks, Bhupal

Bhupal
  • 67
  • 3

1 Answers1

0

You can have Azure Stream Analytics job to do that.It would read message sent in Avro format and then act on it based on a rule. Pleas refer to this doc on how to use SQL Azure as your reference data in RuleEngine

http://learniotwithzain.com/2019/08/alert-engine-using-azure-stream-analytics-and-sql-azure-as-reference-data/

Few more links to help you with that: Rules engine for Stream Analytics on Azure

https://learn.microsoft.com/en-us/azure/stream-analytics/stream-analytics-threshold-based-rules

An alternative option would be to use AzureFunctions also but that would need you to do all the underlying stuff which is pretty easy with Azure Stream Analytics.

An example of Azure Functions: Here the message is intercepted and then passed to a different eventhub after

    [FunctionName("IotDeviceAnalytics")]

    public static async Task Run(
   [IoTHubTrigger("iothub-eventhubname", Connection = "IotHubConnectionString", 
    ConsumerGroup = "consumergroup")] EventData[] events,
    [EventHub("eventhubconnectionstring", Connection = 
    "EventHubConnectionString")]IAsyncCollector<string> outputEvents,
    ILogger log)
    {         

        foreach (EventData eventData in events)
        {
            //eventData would have your message

        }
    }

But as with all components of Azure please do check cost and size limitations. Using SQL Azure as reference data for rule engine has limitation on size of Rule that can be saved as reference data.

Zainu
  • 120
  • 1
  • 7
  • Thanks Zainu, I did considered stream analytics path however I was trying to explore if its possible to use Alert Rules ( under IOT Hub Monitoring) itself so that I can avoid additional azure resources (like stream job...). Seems alerting rules under IOT Hub support only configuring rules on device meta data (when message sent/received etc...) and not on data/message values. – Bhupal Sep 23 '19 at 06:28
  • Nothing which I am aware of. The nearest which would work in ASA. – Zainu Sep 23 '19 at 11:31
  • Yes, seems ASA is the only option. Thanks. Bhupal – Bhupal Sep 24 '19 at 12:12