[Update 15-01-2018]: The issue is being fixed asap. I have been notified the dialogs of Azure Stream Analytics will be changed in a couple of days. This blog will remain valid, though.

[Update 13-01-2018]: It seems the IoTEdge-ASA integration is suddenly not available in the Azure Portal. Eg. the Environment Host question shown below is dropped and no Edge Hub input or output is selectable anymore. No idea why… When more information is available, a new update will be posted here.

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.

But that initial (EventHub?) integration was not quite intuitive and I had more projects to work on. So I moved on.

Now, I had a second chance to make the Photon work!

The first steps are to register your unique Photon device and attach it to the internet (it has a Wifi chip onboard).

If you go to the online IDE, you can write code for your Photon and flash (deploy) it ‘over the air’. This is fun, as long as your Photon is online (wherever it is running), you can contact it using a browser.

The integration tutorial, the blog of Jon Gallant, is very straight forward regarding making an Azure IoT Hub integration. You only need an Azure IoT Hub and a specific access policy. This will help you in sending a string from the Photon to the hub.

Update: Another useful tutorial comes from the Particle site and it shows how to send some integers.

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