Take back control over IoTHub messages in Azure Functions

Azure Functions are a blessing for IoT solutions. To be so flexible executing code whenever messages are arriving, every IoT project is fully depending on it.

But one of the biggest frustrations is the casting of (EventHub) messages towards a string! Only the message body is left! Once a message is passed on to an Azure Function, I only have access to the body of the message. I can not access the (routing) properties anymore.

And before we got Azure Functions, we had to work with Stream Analytics. And I still do! And it’s so nice to have access to the IoT Hub values like the device name of the message. Because I am working with Azure Functions, I have to put it in the Message body first???

It would be great to have access to both the properties and the IoTHub values!

Well, it’s possible now with some clever casting…

Continue reading “Take back control over IoTHub messages in Azure Functions”

Advertenties

Writing commands to IoT Edge Modbus Modules

Microsoft provides several out-of-the-box modules for their Azure IoT Edge platform. If we do a quick search at the Public Docker repository, we see modules like

  • microsoft/iot-edge-opc-publisher
  • microsoft/iot-edge-opc-proxy
  • microsoft/azureiotedge-modbus-tcp
  • etc,

I already have described in a previous blog, how to consume and read data from that Modbus module. After checking out the documentation and some testing, I found out how to write commands back to the device too.

Let’s check out how we can use this in a Custom C# module. After that, we use it in an Azure Functions Module. So let’s do a deeper dive into Azure Functions on the IoT Edge as well.

Continue reading “Writing commands to IoT Edge Modbus Modules”

Part 2: Passing data from outside an Asp.Net MVC Core site to the browser using SignalR

In my last blog, I show how you can implement SignalR on a website running Asp.Net MVC Core. Although the libraries are still in Alpha, the functionality looks very promising.

In this blog, I will show you how you can pass data on to the website so it can be shown in the browser. Users will ‘instantly’ see updates coming on the website.

Let’s check this out.

Continue reading “Part 2: Passing data from outside an Asp.Net MVC Core site to the browser using SignalR”

Migrating Azure Functions from portal to Visual Studio

Azure Functions are a great addition to the whole family of Azure resources. Azure Functions are my number one workhorses. The fact that I can execute code, triggered by ‘whatever’, gives me so much power for a fraction of the costs.

And the beauty of it is, you can write those nifty pieces of code directly into the Azure portal using nothing more than a browser.

But as always, with great power comes great responsibilities!

The code I write in the portal is not supporting any version control. And I cannot debug this code.

Although I am up-and-running with Azure Functions in a few hours, I want to debug and put my code in version control too!

Luckily, I can create Azure Function in Visual Studio too. And this gives me the power of debugging and version control. But what are the drawbacks?

Let’s explore om how to migrate your Azure Function, written in the portal, into Visual Studio.

Continue reading “Migrating Azure Functions from portal to Visual Studio”

Using an External Table output in Azure Functions

As seen in my previous blog, I am experimenting with passing data to a SqlAzure table using Azure Functions.

I first used the new and apparently experimental External Table output available in Azure Functions. Experimental just means in preview.

Due to throttling issues, I had to abandon it where I wanted to insert multiple (+200) records.

But this Azure Functions output is a very promising way to insert records in all kinds of data sources. I can recommend using it when you want to insert, alter or lookup data.

Let’s take a closer look.

Continue reading “Using an External Table output in Azure Functions”

Passing JSON arrays to SqlAzure from Azure Functions using OPENJSON

During my last project, we had to pass arrays of data to SqlAzure.

Normally, passing data is not that interesting. But we were passing data in bulk to SqlAzure so there is always a chance of throttling.

This is when you pass correct records towards SqlAzure but you reach certain limitations eg. if you hit the DTU limits.

We were getting a few hundred records which we first inserted one by one (using the ExternalTable (experimental) output). But we only we able to insert approx. forty records.

So we switched back to a stored procedure.

The second challenge was how to pass an array of records. Because we got the data as JSON, we wanted to pass an array of records like JSON.

In the example below, I show how to call a stored procedure within an Azure Function. The code could be simplified if not I wanted to do some transformations.

Continue reading “Passing JSON arrays to SqlAzure from Azure Functions using OPENJSON”

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”