The other day I came across casbin (, which in my opinion is a flexible authorization framework with support in multiple languages.

Before you hop onto casbin there is 2 basic points to get over which is not explained well in the docs.

The first is – in Casbin there is a model which defines how your permissions are setup. It is a like a generic formula that specifies how the permissions should be enforced.

Looking at the model at first glance looks a bit like greek, but it takes a bit of diving into the docs to realize how the model is put together. So a better place to start at would be the 2nd item.

The Policy – the policy where you can define who has permissions to what. So a basic example would be this :-

which says policy – alice can read data1 & policy – bob can write to data2. How the policy is enforced is through the model

which says each request takes the format of subject, object, action, and how to match the policy.

Read up more in there docs
Overview · Casbin

Check Those Nuget Package Versions People

Learnt a lesson today.

I had a problem today. It’s a simple problem, maybe even a dumb problem, but the reason I am writing this post is so that you who might run in to the said dumb problem might now what to look out for.

The problem is I had an interface like this

public interface IRepository<T>


                /// …. blah blah blah


Implementation of said repository as

public class MyRepository : IRepository<Model>


                /// … blah blah blah


Above interface was packaged up to a nuget package (lets call it MyInterfaces).

Above repository was in a class library (lets call it my MyRepos)

But when trying to register my Repository in core DI container (even autofac’s) it kept complaining that MyRepository does not implement IRepository<Model> and for the longest time I couldn’t figure it out.

Turns out the nuget used in MyRepos was not the latest one.

So, the lesson – just looking at the code to determine the cause of the error was not sufficient. You might also need to look at the nuget package versions to ensure everything is on the same page.

Programatically Adding Azure AD Groups to SharePoint Online

In order to add a user to SharePoint online, you need to EnsureUser first.

I.e. through code

var user = Web.EnsureUser(userName);



The above code works for users, but as of recently has started failing to Ensure AzureAD groups. The reason to me is unknown.

The solution I have found Is not to Ensure the user / Group by their Login Id, but instead use their Claims id.

Coloring on the Microsoft Surface using Sketchbook

Lets face it coloring pictures gives anyone a some sense of satisfaction. You may deny it but deep down you know that even though you may be wasting time in this hobby there is at little a miniscule bit of satisfaction you get out of it.
My toddler who is now 3 loves coloring, and sometimes wants me to color with her. Sometimes we do separate pictures at the same time, or we do different parts of the same picture together.
Added to this added coloring is a growing fad and I have seen numerous coloring books geared towards adults to satisfy this hobby at the stores.
So along these lines I would have expected the Surface to be excellent at this. It comes with a Pen, and so there should be some really good apps for coloring. Which is what I thought. Although there are apps, none of them are good or give the same satisfaction as coloring on paper.
So here is a tip you can use to satisfy your coloring urges.
You need 2 things
1. An app called Sketchbook by Autodesk
2. Google Image Search.
Sketchbook is a wonderful app you use for sketching. drawing etc. I use it to make wireframes of screens, and UI mockups.
Sketchbook supports layers. So here is what I do for coloring.
    1. Do a google image search to find a  coloring template you want to use. For example this.
    2. Once you find the image you want, copy it.
    3. In Sketchbook open the layers panel.
    4. image1
    5. In the Layers Panel choose paste from the layers menu
    6. image2
    7. This will paste a template for you to color on
    8. image3
    9. Add new layer above and then start coloring.
    10. Change the new layers blend mode to darken so that the outlines show through the new layer.
    11. Image4

    Here is a coloring my little one did.


    Evolution of Anonymous Functions in C#

    Most of the time when we use a feature of a language we are not really aware of the evolution of that feature, how that feature has changed over time to make it easier to use. C# now being well over 15, anonymous functions is one such feature. Today most of us write
    ()=>{ //method content here };
    without realizing that there has been a certain evolution over time of the above to make it easy to use as it is today.

    This code snippet in the “docs” (linked shows a good example of how anonymous functions have evolved. Full details

    delegate void TestDelegate(string s);
    static void M(string s)

    static void Main(string[] args)
    // Original delegate syntax required
    // initialization with a named method.
    TestDelegate testDelA = new TestDelegate(M);

    // C# 2.0: A delegate can be initialized with
    // inline code, called an “anonymous method.” This
    // method takes a string as an input parameter.
    TestDelegate testDelB = delegate(string s) { Console.WriteLine(s); };

    // C# 3.0. A delegate can be initialized with
    // a lambda expression. The lambda also takes a string
    // as an input parameter (x). The type of x is inferred by the compiler.
    TestDelegate testDelC = (x) => { Console.WriteLine(x); };

    // Invoke the delegates.
    testDelA(“Hello. My name is M and I write lines.”);
    testDelB(“That’s nothing. I’m anonymous and “);
    testDelC(“I’m a famous author.”);

    // Keep console window open in debug mode.
    Console.WriteLine(“Press any key to exit.”);

    Moving an Azure VM across Subscriptions (as of Feb 2018)

    Recently i had to copy/move an azure VM across subscriptions and was looking for an easy way to achieve this.

    I came across this good post by Laurelle on how to do just this. However the thing is as with most things Azure, the azure landscape has changed so this is an update to the good work done by Laurelle.
    And since things might change again in Azure this post is good as of Feb 2018
    So if you want to copy/move a vm across subscriptions here are the steps.

    Step 1: Copy/Move the vhd across blog storage accounts

    Follow Step 1 of Laurelle’s post.


    Step2: Create a Disk from a VHD

    Using the new Portal, search for Disks in the “All Services” Category


    Withing Disks choose to create a new Disk.
    Fill in all the required information as below, however for Source type choose Storage Blog,
    and for Source Blob browse to the vhd image you copied.


    Step 3: Create the VM from the Disk

    Once the disk is created, selected it, and from the overview blade select “Create VM”
    This will bring up the Create VM wizard in Azure which you can then follow to create your VM

    The Journey of this Blog

    I was looking back at the journey of this blog and how it was hosted recently as I finally moved it to WordPress, and thought its journey was interesting.

    This blog has come a long way as it has now been hosted on 3 different blog engines. Originally I blogged on this was around 2004 I think (I could be mistaken). 2 years later Community Server had just come out, it was the first ever blog engine running on .net. So being the tech adventurer that I am, that is what I did – I mean, I set up Community Server 2 and migrated my blog content to it, about 5+ years later I changed the blog engine to, and now in 2016 its on WordPress.

    Community Server 2 -> -> WordPress