Hi Microsoft 365 devs !
This is the Part II of my post series about Microsoft Graph Subscriptions. If you missed Part I and you want to learn about the fundamentals of Microsoft Graph, it is this way !
In Part I, we discovered the concepts of Subscriptions, how to create a subscription and how to implement a very basic endpoint using Azure Functions from Azure Portal. In this Part II, we will
- See what professional tools we can use to develop an Azure Function
- Write some boilerplate code in order to be efficient when developing Microsoft Graph Subscriptions endpoints
Developing Azure Function like a Pro
In Part I, we wrote a very simple Azure Function on top of NodeJS runtime (we wrote JavaScript) and we did it directly from the Azure Portal. It is very useful to try out and experiment some concepts, but whenever you start real development, you want to be efficient, productive and write code you will be eager to maintain !
In this post I will be using Visual Studio Code and its wonderful Azure Function extension, you can also develop Azure Function with Visual Studio IDE or even with other editors, but it requires extra steps to setup your deployments. In this case, I will focus on development and deploy straight ahead, but one should probably keep in mind than on bigger projects, a better approach would be to use a deployment pipeline (CI/CD).
Some prerequisites
If you don’t have Visual Studio Code, you can download it here.
Today, we are going to write our Azure Function on Node.js runtime again. That means you will need to have Node.js installed on your computer. But this time, however, we will use TypeScript instead of plain JavaScript !
you will need to install globally the npm package azure-functions-core-tools
npm install -g azure-functions-core-tools
And in VS Code install the Azure Function extension, by default you can press Ctrl+P, and then type
ext install ms-azuretools.vscode-azurefunctionsPreview
(Or you can also search “Azure Functions” from the extension gallery and install it)
Once installed, you will get a new available tab in VS Code where you can sign in to your Azure Account and see all the Azure Functions you have access to.
With these tools, we will not only write our Azure Functions in our code editor with all our preferred features, but also, we will be able to run the Azure Function locally on our computer during development time, it eases testing and debugging ! In order to do that, we will also need the .NET Core runtime.
Let’s code (a bit)
Finally, we have all the prerequisites checked ! Now let’s code ! We can start by creating a new project using the dedicated button “Create a new Project…” in our Azure Functions extension
- Select the folder of your new project
- Select “TypeScript” as the language
- Select “HTTP Trigger” as the first function template
- Call it whatever your like (e.g. Webhook)
- Select “Anonymous” as the authentication level
- Select the VS Code window to open in (doesn’t matter here, it’s up to you)
The extension scaffolds the project for us with a bunch of files.



That’s all for Part II !
While I initially planned to cover a bit more in this Part II, I think it’s already quite a few things here. The next thing I want to cover is handling subscriptions lifetime which can be quite long on its own, so I prefer to have a Part III dedicated to it. We will leverage multiple Azure Functions as well as PnP JS !
Stay tuned and see you soon here for Part III !
Cheers,
Yannick