Monday, July 25, 2016

FAAS: Serverless architectures with Function as a Service

After PAAS(Platform as a Service), IAAS(Infrastructure as a Service) and SAAS(Software as a Service), it is now time for FAAS; Function as a Service.  FAAS is one of the incarnations of Serverless architectures(BAAS, BackEnd as a Service is another one).

Let’s have a look at what Microsoft has to offer in the FAAS space; Azure Functions.

Azure Functions is a serverless event driven experience that extends the existing Azure App Service platform. These nano-services can scale based on demand and you pay only for the resources you consume.

Getting started

  • Go to the Azure Functions product page. Click on the big green Get started button.

image 

  • Log in with an account linked to an Azure subscription.
  • If you logged in succesfully, you’ll be redirected to a Get started page(an Angular 2 app Smile) where you can configure the following information
    • Your subscription: select one of the associated subscriptions for this account
    • Name: select a name for your Azure Function(should be unique)
    • Region: select a target region
  • Click on the Create + get started button.

image

  • After the Azure function is created, you will be redirected to the Azure portal where you are welcomed by a Quickstart screen.

image

  • Let’s walk through the  Quickstart.
    • First we choose one of the sample scenario’s; let’s pick the Timer scenario.

image

    • Second choose a programming language. At the moment C# and JavaScript are supported.

image

    • Click on the Create this function button to complete the Quickstart.
  • And there we have it, our first Azure function:

image

Wednesday, July 20, 2016

Using work item templates in TFS 2015 and VSTS

Last week I heared a colleague that he had to customize the TFS work item templates to prepopulate some fields with default values. I had some good news for him. TFS (and VSTS) has a nice productivity feature; work item templates. With work item templates you can quickly create work items which have pre-populated values for your team's commonly used fields. And that’s exactly what he needed.

Here are the steps required to create a work item template:

  • Open the TFS web portal
  • Go to the Work hub and click on the Queries tab

image

  • Click on New and choose the Work Item type you want to create a template for

image

  • On the New Work Item form fill in the default values you want the template to contain. Next,
    • If you are using VSTS choose the Copy template URL option from the context menu:

image

    • If you are using TFS on premise, click on the Copy template URL button:

image

  • An URL is generated and copied to your clipboard. Here is an example of the generated url:

https://mysubscription.visualstudio.com/SampleProject/_workItems/create/Task?%5BSystem.Description%5D=Default+description&%5BMicrosoft.VSTS.Scheduling.RemainingWork%5D=20&%5BMicrosoft.VSTS.Common.Activity%5D=Development

  • You can now share this url or put it for example on your TFS dashboard

Remark: If you don’t want to use the web portal but use Visual Studio or Team Explorer most of the time, you could use the Work Item Templates feature as part of the TFS Power Tools extension.

Tuesday, July 19, 2016

Microsoft REST API guidelines

If you ever build a REST(like) service, you know that there is no one ‘right’ way to build such a service. Okey, you have the HTTP specs and the REST dissertation by Roy Fielding but this still keeps a lot of questions unanswered:

  • How do you handle versioning?
  • When do you use which HTTP status code?
  • What metadata do you add to your headers?
  • How do you return error data?

In an effort to structurize all REST services build by Microsoft in the same way, they made their REST API guidelines publicly available:

The Microsoft REST API Guidelines, as a design principle, encourages application developers to have resources accessible to them via a RESTful HTTP interface. To provide the smoothest possible experience for developers on platforms following the Microsoft REST API Guidelines, REST APIs SHOULD follow consistent design guidelines to make using them easy and intuitive.

This document establishes the guidelines Microsoft REST APIs SHOULD follow so RESTful interfaces are developed consistently.

If you have to decide on your own standards to use inside your organization or you want to consume a Microsoft REST service, this guide is certainly worth a look.

Content:

MICROSOFT REST API GUIDELINES

Monday, July 18, 2016

Cloud Design Patterns infographic

I shared some great resources regarding Cloud related design patterns before:

Here is another one to add to the list:

  • Cloud Design Patterns Infographic: An interactive infographic that depicts common problems in designing cloud-hosted applications and shares design patterns to solve them.

image

Friday, July 15, 2016

TFS Build Test Task–How to exclude a set of tests

The Test Task in TFS Build allows you to specify which assemblies should be searched for (unit) tests.

image

image

By using the Test Filter criteria, you can further filter the set of Tests you want to be executed:

image

Based on the Tooltip you get the impression you can only specify which tests to include based on things like TestName, TestCategory, … But under the hood there is a lot more possible. You can not only include tests(using ‘=’), but also exclude tests(using ‘!=’), execute a contains check (using ‘~’) and group subexpressions (using ‘( <subexpression>)’).

Here is a short sample where I exclude all PerformanceTests, include tests with Priority 1 and where the name contains the word ‘UnitTest’:

image

Thursday, July 14, 2016

NUnit 3: Trace.WriteLine not captured in Test Explorer

After upgrading to NUnit 3, I noticed that no Tracing information was captured and written to the Test Output. (Note: I didn’t verify but I’m quiet sure it worked when using NUnit 2.x)

After searching through the documentation and Issues list on GitHub, I found the following quote:

“Currently, the "channels" we capture are Console.Out, Console.Error and TestContext.Out. ”

So indeed no Trace.Write(Line) in the list. Let’s check if this statement is correct…

Here is my test code:

image

And let’s now have a look at the test results:

  • Trace.WriteLine – no output available Sad smile:

image

  • TestContext.WriteLine – with output Winking smile:

image

image

Wednesday, July 13, 2016

Testing your Akka.NET actors using TestKit

Due to the nature of Actor based systems, they can be complex to test. Luckily Akka.NET, the actor framework of my choice, is accompanied by Akka.TestKit, a library that makes it easy to unit test Akka.NET actors.

How to get started?

Akka.TestKit has support for the most popular test frameworks for .NET; MSTest, XUnit and NUnit.

As I’m a long time NUnit user, I show you how to set it up using NUnit, but the steps for other frameworks are similar.

Step 1- Download the correct NuGet Package

For every test framework a seperate NuGet package is available, as I will use NUnit, I download the Akka.TestKit.NUnit3 nuget package. (If you are still using an older NUnit version, a separate package is available; Akka.TestKit.NUnit.

Step 2 – Initialize your test class

Every test class should inherit from TestKit. This class provides all the necessary wiring, setup and cleanup of the actor system and a range of helper methods.

Step 3 – Create an actor

Inside every test an ActorSystem instance is created making each test completely isolated. This ActorSystem is available through the Sys property on the TestKit class. You can create an actor using the Sys property or use the ActorOfAsTestActorRef method:

Step 4 – Send messages to your actor

Once your actor system is created, it’s time to start sending some messages:

Step 5 - Assert for results

Finally you can check for results. If you don’t expect any messages to be returned, you can use ExpectNoMsg() otherwise you can use the ExpectMsg() method: