Sending Notifications in Microsoft Teams apps

For my Microsoft Teams apps I recently added support for Teams-native notifications. This allows me to conveniently send notifications through Microsoft Teams without having to manage some kind of push service myself.

These notifications can be sent through Microsoft Graph which I’m doing using the On-Behalf-Of-Flow, meaning this only works when a user with the required permissions is performing an action that will trigger a notification.

Here’s how I did it:

Continue reading Sending Notifications in Microsoft Teams apps

Streaming File Downloads from Azure Blob Storage through ASP.NET Core

Often times when working with Azure Blob Storage you don’t want to expose access to the service directly but rather have requests go through your own API. This allows you to control access and hide the underlying service. However, you need to be careful to not put unnecessary extra load on your service during file operations by buffering up- or downloads in memory. You may not notice this at first for smaller files like images, but I can severely impact your service performance when larger files are in play.

Continue reading Streaming File Downloads from Azure Blob Storage through ASP.NET Core

Azure SignalR Serverless with Azure Functions v4 Node

For my Microsoft Teams apps Zeitplan.io and Team Schedule, I recently implemented auto-updates of the calendars using SignalR to trigger the reload whenever a change was made. Since both apps run with Azure Functions on Node/TypeScript as the backend, I chose the Azure SignalR service in serverless mode. The functions are connected via Managed Identity to negotiate between the React frontend and the Azure SignalR service.

Continue reading Azure SignalR Serverless with Azure Functions v4 Node

Testing Azure Functions v4 Node & TypeScript with Jest

To write and run tests for Azure Functions with Node / Typescript, we need a bit of extra setup. We’ll start with a new function project with an http trigger and then add the required dependencies:

npm install --save-dev jest typescript ts-jest @types/jest ts-node

I added ts-node as an additional dependency which is not listed in the ts-jest Getting started but required to run the tests.

Continue reading Testing Azure Functions v4 Node & TypeScript with Jest

Deploying to Azure Static Web Apps in Azure DevOps

I have started moving several static websites & SPAs from “Static website hosting in Azure Storage” to Azure Static Web Apps (SWA). Main reason for this is the limitation of using apex domains with Azure CDN which is the only way to use custom domains on websites hosted with Azure Storage. This is not an issue with Static Websites where you can use ALIAS, CNAME or A Records to map your domains. And with two custom domains available in the free tier this is now my go-to default.

Continue reading Deploying to Azure Static Web Apps in Azure DevOps

Azure Functions + Storage with Managed Identity via Bicep

Today I needed to migrate an Azure Functions project that used to connect to Azure Storage with a normal connection string. Since that’s prohibited by policy in my new Azure subscription, we needed to change that.

This also meant we needed to move the Function App to a dedicated plan since Managed Identity is not supported with Consumption or Elastic Premium plans.

Continue reading Azure Functions + Storage with Managed Identity via Bicep

Allow Client Credentials Flow in ASP.NET & Microsoft.Identity.Web

For authenticating Entra ID users & services in ASP.NET you’re probably using the Microsoft.Identity.Web with some initialization code looking something like this in your Program.cs:

This will configure authentication based on the values stored in your appsettings’ “AzureAd” section. And it should work fine with “normal” users, but it will not accept Tokens from a Client Credentials Flow that might be used for Service-to-Service communications.

Continue reading Allow Client Credentials Flow in ASP.NET & Microsoft.Identity.Web

Service-to-Service comminucation with Refit & Client Credentials Flow for Entra ID

For a recent project I needed my ASP.NET Core backend service to talk to an external license server using the Entra ID Client Credentials Flow for authentication. For these scenarios I like using Refit to generate the required http client logic. And adding auth for Entra ID is pretty straight forward as well if you know which libraries to use.

Continue reading Service-to-Service comminucation with Refit & Client Credentials Flow for Entra ID

Read request headers in Azure Functions v4 with Node

I often have to read information from request headers in Azure Functions. For example to get the User Object ID that made an authenticated call. This is a bit more tricky than just calling request.headers[‘x-ms-client-principal-id‘]. This is valid TypeScript but will always be undefined!

Continue reading Read request headers in Azure Functions v4 with Node