Getting started with Azure Command Line Interface 2.0 (CLI)

Adding new Azure resources to your subscription can be done multiple ways. The most common way, of course, is adding resources by hand in the Azure Portal. But this is error prone and tedious. To manage your azure resources in a professional way, you need ‘better’ tooling.

A viable solution is making use of Azure Resource Manager (ARM) templates. This is very popular but it has a certain learning curve.

And it’s also possible to make use of Azure integration of power shell. Again, there is a certain learning curve.

Let’s look at another solution, the Azure Command Line Interface (CLI). What if you could manipulate resources using the command line in a dos box? What if you could add a resource group like this, in one line:

az group create -n cli-rg -l westeurope

This looks easy, doesn’t it?

The CLI is quite new, and it’s available on multiple platforms (Windows, Linux, MacOS, etc.). It’s built on top of Python so you have to install that tool first.

Let’s make this happen. Let’s install and run the CLI. In this example, I use a Windows machine but there are installation guides for other operating systems available too.

Continue reading “Getting started with Azure Command Line Interface 2.0 (CLI)”

Using Node.js to access Azure IoT Hub

By now the Cloud strategy of Microsoft must be very clear. It’s not about Windows, it’s not about Office, it’s not about Microsoft programming languages even. Microsoft is opening up towards all devices, operating systems, programming platforms, etc. Everybody is welcome in the cloud.

Although this is going on for quite some time, it is still a surprise for quite a few non-Microsoft developers. So today I decided to program against the Azure IoT Hub using another language, just to check out their experience.

Microsoft supports multiple programming languages, there are multiple SDK’s available:

If your favorite language is not listed here, but it talks MQTT, AMQP or HTTP, chances a big you can build your own SDK.

Today I picked up Node.js because I know a bit of javascript 🙂 Let’s check out what Javascript developers have to do to connect to an Azure IoT Hub.

Continue reading “Using Node.js to access Azure IoT Hub”

Adding trace message logging in Azure WebJobs

When I noticed the arrival of the Web jobs SDK 2.0, I remembered an issue I had with logging traces in Web jobs. But before we come to that, let’s check out trace logging in general in a Web job.

Adding Trace messages to a Web job does not seems to be that hard. Just open the Visual Studio Web job template, create a new Web job and open the Function file.

There is already one function in the Web job template. Here, I just add several kinds of logging. Next to Trace logging, I make use of both the log.writeline() and the console.writeline() (because we are in a ‘kind of’ console app):

public class Functions
    // This function will get triggered/executed when a new message is written on an Azure Queue called 'queue'.
    public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
        var ts = new TraceSource("Diagoutput");

        ts.TraceEvent(TraceEventType.Verbose, 1, $"ProcessQueueMessage verbose trace {message}");
        ts.TraceEvent(TraceEventType.Information, 1, $"ProcessQueueMessage info trace {message}");
        ts.TraceEvent(TraceEventType.Warning, 1, $"ProcessQueueMessage warn trace {message}");
        ts.TraceEvent(TraceEventType.Error, 1, $"ProcessQueueMessage err trace {message}");
        ts.TraceEvent(TraceEventType.Critical, 1, $"ProcessQueueMessage crit trace {message}");

        log.WriteLine($"ProcessQueueMessage log {message}");

        Console.WriteLine($"ProcessQueueMessage Console {message}");
        Console.Error.WriteLine($"ProcessQueueMessage Console Error {message}");

Continue reading “Adding trace message logging in Azure WebJobs”

Azure Stream Analytics built-in geospatial functions

Azure Stream Analytics has had severe important updates the last few months. And these updates make the Azure Stream Analytics job even more powerful.

Microsoft has added the ability for adding your own JavaScript functions. And the job is integrated into Visual Studio (2013 and 2015) using advanced tooling.

Working with Geo coordinates has alway intrigued me. So the third major update is my favorite: built-in geospatial functions.

There are three functions for supporting GeoJSON objects:

  1. CreatePoint. Returns a GeoJSON Point record
  2. CreatePolygon. Returns a GeoJSON Polygon record
  3. CreateLineString. Returns a GeoJSON LineString record

So we have points, lines and areas.

And there are several functions for checking out the relation between these records:

  1. ST_WITHIN. Check if a point lays within an area
  2. ST_OVERLAPS. Check if an area lays within another area
  3. ST_INTERSECTS. Check if two lines overlap
  4. ST_DISTANCE. Calculate the distance between two points in meters

Let check this out using Stream Analytics.

Continue reading “Azure Stream Analytics built-in geospatial functions”

Flexible message routing in Azure IoT Hub using C#

The Azure IoT Platform is a very versatile solution for all your IoT needs. Azure supports multiple resources for storing large amounts of data, querying immense streams of data coming in, having event buses which can hold millions of messages, serverless functions, reporting and Machine Learning; what more do you need?

But it all starts with the IoT Hub:

“Azure IoT Hub is a fully managed service that enables reliable and secure bidirectional communications between millions of IoT devices and a solution back end”

Normally, whenever I start a new IoT Platform solution in Azure, I start with an IoT Hub and connect it to a Stream Analytics job as an input source. Messages arriving at the IoT Hub are then passed directly into the Stream Analytics job to be examined. And the Stream Analytics job can pass some or all messages (or transformed messages) to multiple output sinks eg. Event Hubs, Service Bus Queue or Topic, Blob Storage, etc.

The arriving messages carry telemetry information from the device. But what if the messages are sent in a certain context? What if a message has a high or low priority? Should we pollute the message with this ‘routing’ information? And Act on it inside the Stream Analytics job?

A few week ago, Microsoft introduced a new feature in IoT Hub, called message routing.

This makes it fairly easy to react on difference messages, arriving at the same IoT Hub, but intended to handled differently. Routing is perfect for this matter. We can declare extra endpoints directly in the IoT Hub. And depending on message properties, messages can be sent directly to these endpoints:


There are two important things to keep in mind. First, the message properties are extra annotations (defined by the IoT Hub device client), we are not peaking inside the message itself. And second, messages can still end up in a Stream Analytics input when it is ignored by the active routes.

Let’s take a closer look.

Update 2017-06-01: Microsoft announced that routing is now supporting values from the actual telemetry, great news and now it’s more intuitive!

Continue reading “Flexible message routing in Azure IoT Hub using C#”

BBC micro:bit Impressive introduction into programming

This weekend, I got a BBC micro:bit from a friend. This is a nice gift indeed, I had and still have lot’s of fun with it.

Before I tell a bit more about the device, did you know each 11- and 12- year-old student in the UK got one for free!? That’s more than one million devices. This is a great opportunity for kids: they can learn about programming, computers and most of all, programming and computers can be fun!

The design of the device is very clever!

It has an ARM processor, two buttons, 25 leds (which acts like a screen), a compass, an accelerometer, Bluetooth LE, GPIO pins, a battery connector and a MicroUSB connector (for programming).


Programming is so easy! Let’s dive into this a bit deeper…

Continue reading “BBC micro:bit Impressive introduction into programming”

How to send Azure IoT commands back to NodeMcu

Microsoft is has made their IoT platform very open. There are lots of ways to connect to it, using various protocols like HTTP, MQTT and AMQP. And Microsoft provides multiple SDKs to connect to their IoT platform using languages like Python, .Net, Java, Node JS and C. So it’s not that hard to connect to the platform whatever your development platform is.

If you follow my blog, you will notice that I normally connect to the platform using UWP. It’s great for testing purposes and it even runs on a Raspberry Pi using Windows 10 Core. I also connect a lot using ‘special’ Arduino’s. Although these are not connected to the Internet by default, I have a couple of The Things UNO boards which have wireless connectivity using Lora. The Arduino’s connect to the Azure IoT platform using the The Things Network Lora platform.

I also connected using a Photon, using the Particle cloud. This works almost out of the box but for now, it’s only one way; I can only send telemetry to the Particle cloud. I hope to see the ability for receive commands,  arriving at the Photon, in the near future.

Currently I have some NodeMCU laying around and a friend showed me how to connect to the Azure IoT Platform using the Azure IoT for C SDK.


It’s not that hard to get it to send some telemetry, once you know what to do (thanks, Jan Willem 🙂 ) but retrieving commands is less straight forward. In this blog, we take a closer look.

Continue reading “How to send Azure IoT commands back to NodeMcu”