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”


Tweede Azure IoT Community bijeenkomst op 1 februari 2018

Op 1 februari 2018 wordt al weer de tweede Azure IoT Community bijeenkomst georganieerd!

Na de succesvolle eerste bijeenkomst wordt het weer tijd voor een nieuwe mogelijkheid om elkaar te ontmoeten.

Deze avond is voor iedereen die geinteresseerd is de combinatie van Microsoft, Windows, Azure en natuurlijk IoT. Het maakt niet uit of je nu hobbyist, student of professional bent. Kom lang, neem je vrienden mee en deel jouw ervaringen of doe juist ervaring op.

Het programma voor deze avond is:

17.30 – Inloop en eten

18.30 – Korte introductie en laatste updates van Microsoft IoT producten

18.40 – Industrial IoT with Azure IoT Hub – door Eldert Grootenboer / Motion10

19.30 – Alles over de Azure Stream Analytics

20.15 – Borrel

De avond is dit maal verzorgd door Atos, de locatie is Burgemeester Rijnderslaan 30 in Amstelveen (routebeschrijving)

Dus meld je aan op via deze link (en neem legitimatie mee).

Meer informatie is te vinden op onze website. Tot ziens op de volgende bijeenkomst!


Introduction to the IoT Edge SDK V1, part 6: Modbus for Wise modules

Update: Recently, Microsoft introduced the new V2 version of their IoT Edge. This blog is referencing the former but still supported V1.

I do a lot of IoT research using the Advantech Wise 4012E IO module. It’s biggest advantages are that it runs on 5 Volts, using a MicroUSB connection (instead of a bulky 12V or 24V adapter) and it comes with knobs, switches and LEDs to simulate real sensors. So it’s a very compact but yet complete IoT device.

Until a few days ago I made use of the Rest protocol to contact that module but this has some disadvantages.

First, Rest is a great protocol in the IT world but it is not used that much in the OT world. Luckily, the IO module also supports the Modbus protocol. So I tried to switch to that protocol.

Second, Rest is very slow compared to other protocols like Modbus. Using Rest, I’m lucky when I can pull 2 or 3 requests a second out of the module.

In the previous blogs, we have seen multiple modules, both provided by Microsoft or created on the fly. And Microsoft provides a genuine Modbus module for the IoT Edge SDK. There is only one drawback, it’s on Github but it’s not available as NuGet package. You have to make/build it yourself!

And for some unknown reason, I did not get it working the way I liked it. I encountered too many exceptions.

Update: There is also a Version 2 of this module. In this blog, I refer to V1.

So, in the end, I just ignored the module and build my own Modbus module.

Continue reading “Introduction to the IoT Edge SDK V1, part 6: Modbus for Wise modules”

User Defined Function in Stream Analytics

Azure Stream Analytics provides a great solution for temporal queries of streams of data. The query language is pretty simple, especially if you have a background in SQL queries.

The list of built-in functions is a long list, ranging from aggregation, analytics, geospatial, records, scalars to the recently introduced anomaly detection.

But what if you want to write your own functions?

Stream Analytics supports three types of custom functions:

  1. user-defined functions (UDF) written in Javascript
  2. user-defined aggregates (UDA) written in Javascript
  3. Machine learning endpoint disguised as functions

In this blog, I will show how easy it is to write and use your own custom logic in a Stream Analytics job. We will look at the user-defined functions.

Continue reading “User Defined Function in Stream Analytics”

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”

Direct methods support in the IoT Hub Connected Service

The Visual Studio 2017 Connected Service for Azure IoT Hub has received an update a couple of months ago.

This update had some visual updates and now supports a Singleton pattern for the Device client too.

But it also included support for both Device twins and  Direct Methods. The latter feature looks a lot like the Commands method but there are some fundamental changes.

Yes, both solutions (Command and Direct Method) can execute code on a remote IoT Hub client. But the remote method just passes a message to the client. The Direct method can pass a message in a certain context. It calls a specific method (a client can have multiple methods registered) and passes the JSON parameter.

If you execute a Command, it feels like fire-and-forget. There is no descriptive response. But the caller of a Direct Method can wait until a response is accepted and a JSON value is returned.

Let’s check out Direct Methods.

Continue reading “Direct methods support in the IoT Hub Connected Service”