Problem using PnP Core GetAzureADAppOnlyAuthenticatedContext() with Azure Functions runtime.

I was working on an Azure Function recently that used the OfficeDevPnPCore AuthenticationManager() class with the GetAzureADAppOnlyAuthenticatedContext() method to get an app only authentication context.

new AuthenticationManager().GetAzureADAppOnlyAuthenticatedContext();

I was running into the very helpful error message of “Object reference not set to the instance of an object”.

After a little digging around I came across the following GitHub issue when pointed me in the right direction.

The problem seems to be with the latest runtime. I was running version 1.0.9 of the Azure Functions Core Tools to locally debug the function.

If you look at the app settings for your function in the portal, you will see that there is a setting called “FUNCTIONS_EXTENSION_VERSION” and this will be set to the value ~1 which means use the latest runtime.

The solution to being able to run this above code on Azure was to force the runtime to use a particular version. I set mine to 1.0.11388 which got everything working again.



However I still needed to debug the function locally so I needed to update my local version of the core tools.

If you open a command prompt and type


you will see which runtime you have installed.


As you can see I had version 1.0.9 installed. I looked through the releases on GitHub at and decided to downgrade my tools to version 1.0.7.

After downgrading to version 1.0.7 I found that the above app only auth call started to work again.



Looking up SharePoint taxonomy terms from Microsoft Flow app using an Azure Function

In this post I am going to show you how you can use an Azure Function to return an item from the SharePoint Online term store and use that value inside a Microsoft Flow app.

As an example of where this might be useful think of something like an approval workflow using Microsoft Flow that can lookup an approver’s email address from the SharePoint term store.

The basic architecture looks like below:


Getting started

The first thing to do is to download the source code from this GitHub repository.

The code includes an Authentication context that supports both App Only authentication and SharePoint authentication through AppRegNew.aspx.

This can be configured by changing the Azure Function app setting called AUTH_TYPE from AppOnly to SPAuth.

Creating Azure AD App

We need our Azure Function to be able to authenticate with SharePoint so we will create a new Azure AD app in the portal and configure it’s application permissions to allow SharePoint access.

Setting up App Only auth is quite lengthy and there is pretty good documentation over on you can follow the steps in this article to create an Azure AD app and then follow this article to configure it for app only authentication

Once you have the Azure AD app created and your app only certificate, make sure you put the .pfx file inside the .\Cert directory inside the solution and set its ‘Copy to Output Directory’ property to ‘Copy Always’. You will also need to update the name of this certificate in the Azure Function app settings in the CERT_NAME setting.

Open the permissions for the newly created AAD app in the portal and make sure the Office 365 SharePoint Online permissions are configure as below:


You will need to make a note of the Application ID for this AAD app and update the AUTH_ID app setting in the Azure Function once created.


Deploying Azure Function

In the Azure Portal create a new Function App as shown below and make a note of the App Name.


Next we want to deploy the function to Azure. We can either download the publish profile from the portal or use the Azure Functions Core Tools library

To use the core tools to deploy make sure you first build the solution. Open a command prompt and CD to .\bin\debug\net461 folder.

After installing the tools with

npm i -g azure-functions-core-tools

Then run

func azure functionapp publish leetestsptaxlookup

Replace leetestsptaxlookup with the function name you created earlier.

Update the functions app settings with the values in the local.settings.json file replacing the values with the ones that relate to your tenant.


Configure the Azure Function taxonomy lookup

The Azure Function will lookup from the term store based on the value in the TERM_GROUP app setting.

For instance if our term store structure look like below:


We would set our TERM_GROUP setting to be the value “Lee;Settings;SiteRequestApprover”. Notice the structure is TermGroup -> TermSet -> Term all separated by a semi colon.


Creating Microsoft Flow App

Open Microsoft Flow and create a new Flow. You can pick whichever trigger you want to use. Create a new HTTP action and configure as shown below:


The HTTP action just makes a GET request to the Azure Function passing in two parameters; siteUrl and code.

siteUrl is the URL of the SharePoint site you want to use as a context for obtaining the taxonomy values. You need to pass your host key to the code parameter. You can view your host keys when you visit the settings page for your function in the Azure portal.


When your Flow is run the Azure function will return the value from the term store inside the body of the HTTP response as show below:


This Body value can then be used as a parameter to other actions. This means we can use a value from the term store to drive decisions within our Microsoft Flow app. This could be something like an approver for a workflow for example. In reality any value can be retrived from the term store and we can host multiple Azure functions for different values.



The blockchain what is it?

Lately I’ve been reading and taking an interest in the technology known as the blockchain. In this article I attempt to outline and explain in broad terms what the blockchain is and how it has the potential to change society in a number of ways.

So what is the blockchain?


Wikipedia has a nice concise definition of the blockchain

blockchain[1][2][3] – originally block chain[4][5] – is a continuously growing list of records, called blocks, which are linked and secured using cryptography.[wikipedia]

So lets break this statement down. First is the continuously growing list of records, which essentially is like a database in the technical aspect in which “rows” or in case of the blockchain “blocks” keep getting added to an ever growing collection of “stuff”

What is this “stuff” we keep adding? Well it can be anything really, anything that can be cryptographically hashed and stored digitally. For example a record of a monetary transaction or a music file or some digital artwork.

All these records are linked together in whats called a “block” which are further linked together in the blockchain and are timestamped and verified.

That’s all well and good but we already have the ability to store data like in in the form of databases. Why are we interested in a blockchain?

Distributed blockchain


The most interesting aspects of the blockchain technology is the fact that it is distributed across multiple parties who verify the blocks by doing some computationally expensive task and all parties have to agree on the correctness of the blockchain entries.

This is a massive difference to most databases that are centrally stored and controlled by one or very few entities.

This means that no one person or company can take control of the blockchain and manipulate it to their own ends.

Think banks and governments that control currency, think record labels that control rights to music and you will get the idea.

Moving to a more distributed society.


If we think in terms of what applications we can use the blockchain for, we can point to the main and most well known application which is the Bitcoin digital currency.

Bitcoin uses the blockchain to store it’s transactions on and to verify and protect users of the currency from things like double spending and fraud.

Bitcoin has no central bank or institution controlling the currency and this means that anyone anywhere in the world can use the currency to purchase good or services, people who would normally not be able to participate in the world of financial services. Billions of people in the world right now still have no access to financial services. What people do have access to is a mobile phone and the internet. This is where blockchain and digital currencies can enable a whole new economy based on distributed ledgers.

The cryptography


Let takes a look at the next statement in the definition that says the blocks are linked and secured using cryptography.

Each piece of data in the blockchain is encrypted with whats called asymmetric encryption (or public key cryptography) which essentially means that you have both a public and private encryption key and every piece of data gets encrypted with your private key. This means that only you have access to the data that is encrypted with your private key.

Data encrypted with a private key can only be verified with the corresponding public key and so a digital signature made up of a hash from a users private key provides a cryptographically secure way of identifying someone (or something).

In the use of Bitcoin and other digital currencies you maintain a “wallet” which is encrypted with your private key and allows the blockchain to verify that the transactions you created (for instance to send some currency to another wallet) are allowed and you are not trying to spend currency you don’t own.

Smart contracts


Smart contracts are in my option the way we are going to use the blockchain going forward. Essentially smart contracts allow users of the blockchain technology to automate transactions and programatically execute workflows that influence the outside world.

For example imagine setting up a contract with a freelance software developer to build you a website. The smart contract can digitally record every detail of the agreement and automate payment once certain milestones have been completed. Once the developer has built the home page you could automate a payment of digital funds directly into her account. The contract is cryptographically secured in the blockchain and distributed between multiple users in the system so it cannot be changed later or disputed.



Blockchain based currencies allow micropayments which would be prohibitively expensive due to transaction fees from banks and payments providers such as Visa. People in countries that can’t use these payments providers because the transaction fees are too high can suddenly participate in an digital economy and they can also store their savings somewhere less risky (rather than things like livestock for instance) and be afforded the luxuries of financials services that developed countries enjoy.

Identities and reputations


When transactions and services are based on the blockchain everything is stored and publicly available to anyone who can read the blockchain. Online identities and reputations can be built up and moved away from central control. Want to get credit? A company could look at your blockchain history and determine exactly how reliable you are instead of relying on the checkbox approach of most credit agencies. More people can participate in an economy based on blockchain technologies than could previously.



Blockchain technology enables a host of new services and economies that was previously either unavailable or controlled centrally by the “key” holders who only really have their own interests in mind.

Distributed ledgers based on the blockchain can free us from the reliance on centrally controlled intermediates and create a more peer to peer society.

I am going to follow this article up with a deeper dive into specific uses and the technical aspects of blockchain implementations.


Passed the BCS Foundation Certificate in Systems Development exam.

I have been a professional member of the British Computer Society for years now and I recently started to take a look at what exams they offer. I noticed they did a foundation certificate in systems development exam which looked like from the website that you could self study using a book.

I wanted to give a BCS exam a try but I didn’t want to pay out for expensive training courses and take time off work. Looking at the exam description page they referenced the BCS book titled Developing Information Systems bcsbook

I bought the book and started reading and studying the material. To my surprise the material in the book was reasonably up to date with modern software development practices and went into most aspects of formal systems development models around today and gave a nice history of where these practices came from.

The book covered the full systems development life-cycle from requirements engineering to business analysis to software development methodologies.

The exam itself was a 40 question exam and the book definitely covers enough for you to easily pass the exam and if you already have a lot of software development experience then most of the material will be pretty familiar to you.

All in all the exam is probably worth doing as the book is worth a read especially if you are new to the industry.  I booked my exam through Pearson Vue which can be accessed from the BCS website.

TypeScript 2, React 15, Bootstrap and WebPack 2 Boilerplate.

I was recently working on a TypeScript project with React that uses WebPack 2 and Gulp for it’s build process.

I thought it would be worth creating a GitHub repository that stores this boilerplate code so that anyone can download the code and get started creating web apps with this particular technology stack.

The source comes with TypeScript, Less, Bootstrap all wired up with React and some base example components to get your started. It also sets up webpack-dev-server so you can easily spin up a local dev server to host your web app while in development.

To get started just run the following to get the code from the repository.

git clone

You should then run an NPM install to download all dependencies.

npm install

Finally you can compile the TypeScript code and run the dev server like so:

gulp webpack

gulp webpack-dev-server

And thats it you should be up and running with your web app.