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)”

Advertenties

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”