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!
Turns out you first have to invoke the .entries() method on the request.headers, so here’s a quick helper method:
So now you can simply get a header value by calling
const userId = readHeader(request, ‘x-ms-client-principal-id‘);