Combining Azure StreamAnalytics with Azure Function Sink

There are many ways to collect data from an IoTHub and pass it through Azure Functions:

  • Trigger an Azure Function directly by the IoTHub events or operations monitoring
  • Trigger an Azure Function using an EventHub or message bus as endpoints of IoTHub routing
  • Trigger an Azure Function using an EventHub as output sink of a Stream Analytics job

All these solutions serve their own purpose.

But the last one, using an EventHub, can be pretty annoying. Yes, this is a great way if you will use the security policies and/or consumer groups of the Eventhub. But otherwise, there is a lot of administration.

Let’s check out how life is becoming much easier with a new Azure functionality which is still in public preview called Azure Function Sink.

Continue reading “Combining Azure StreamAnalytics with Azure Function Sink”

Advertenties

Azure Functions as watchdog for missing telemetry or devices

Once you are working with the Azure IoT platform, there comes a moment where you want to add notifications.

In a previous blog, we looked at how to send notifications when telemetry values did not match certain ranges. Although this is great, there are even more cases where we want notifications.

Here I am referring to watchdog functionality. When no telemetry is arriving anymore or devices are disconnected, the complete IoT platform is not working as designed. So we want to be informed when something fails.

In this blog, we will build a simple watchdog using Azure Functions.

Continue reading “Azure Functions as watchdog for missing telemetry or devices”

The only thing standing between IoT Hub and Functions are Consumers groups

Traditionally, when telemetry arrived at an Azure IoT Hub, it was a rule of thumb to pass it to a Stream Analytics job. But when routing was introduced in the IoT Hub, it became possible to push the telemetry directly into an EventHub or a Service Bus too.

I still favor the many possibilities of the Stream Analytics job, working with temporal and geospatial data eg. is so much easier that way.

But I can configure a lot of other, new Azure resources after the Event Hub or the Service Bus.

For example, IoT Hub routing to an Event Hub makes it possible to pass telemetry to Azure Functions (using the EventHubTrigger). This opens a whole new world of Azure opportunities using only an EventHub in this case! But it can be done even simpler…

Continue reading “The only thing standing between IoT Hub and Functions are Consumers groups”

The output sink format of a Stream Analytics job matters!

When you look at examples of Stream Analytics queries usage, most examples are pretty straightforward. These work with simple queries which return single line output.

For example, a query like:

SELECT
  *
INTO
  huboutput
FROM
  hubinput timestamp by EventProcessedUtcTime

… will return a line like:

{"cycle":4, "errorcode"=1, "deviceid":"MachineCyclesDemo"}

In an Azure Function, this will arrive as:

2016-12-19T15:15:07.045 Function started (Id=e58ea9ec-fd8d-469e-bd9c-ea027ce2dbb4)
2016-12-19T15:15:07.690 Messages arrived: {"cycle":4, "errorcode"=1, "deviceid":"MachineCyclesDemo"}
2016-12-19T15:15:07.690 Function completed (Success, Id=e58ea9ec-fd8d-469e-bd9c-ea027ce2dbb4)

But when the query is a bit more complicated, like grouping with a time interval:

SELECT 
  Count(errorCode),
  IoTHub.ConnectionDeviceId as deviceId
INTO
  arrayoutput
FROM
  hubinput timestamp by EventProcessedUtcTime
WHERE
  errorCode <> 0
GROUP BY IoTHub.ConnectionDeviceId, TumblingWindow(Duration(minute, 1))
HAVING Count(errorCode) > 1 

Then the format of the messages returned can be unexpected.

Continue reading “The output sink format of a Stream Analytics job matters!”

Iot Hub supports uploading files, perfect for Cognitive Services vision

Usually, when I reference the Azure IoT Hub, you can expect that some telemetry is involved. But the Azure IoT Hub is evolving. A new feature is coming, it is now possible to upload blobs.

Why should we want to upload blobs? Well, I think it’s great to have the possibility to upload files full of telemetry in one upload.

But sometimes the telemetry is not a bunch of values but it’s more like a big bag of bytes 🙂 In the example below, we will upload an image and pass it on to Microsoft Cognitive Services  (previously known as Project Oxford) for visual analysis.

Continue reading “Iot Hub supports uploading files, perfect for Cognitive Services vision”

Triggering Microsoft Flow using an Azure Function

For a recent Azure IoT workshop, we were looking for a nice ending of the Azure IoT pipeline. Because after introducing IoT Hubs, Stream Analytics, Event Hubs and Azure Functions, we wanted to show the real power of IoT.

Normally, we show a bunch of charts in PowerBI. You have seen it in my previous blogs, it’s so powerful. But this time, we wanted to do something else, something snappy.

Well, we came up with Microsoft Flow. At first, I was a bit sceptic. Will this help us to ‘sell’ Azure IoT?

Well, see for yourself… Here is an example on how to send, conditionally, an email to an email address you provide.

Continue reading “Triggering Microsoft Flow using an Azure Function”

Azure Stream Analytics job exposes IoT Hub values

Whenever I build a new IoT solution in Azure, I have to build this service chain. I have to connect a string of services like IoT Hub, Stream Analytics Job, Event Hub and Azure Function to have a quick insight in the telemetry coming in.

Today I found out a little feature which saves me a lot of time and now lesser data must be put in the telemetry.

I was under the assumption that a Stream Analytics job just handled plain (json) messages from their input. Now I am able to pinpoint the device the telemetry is coming from, for free, using a nifty feature of the IoT Hub!

Continue reading “Azure Stream Analytics job exposes IoT Hub values”