Azure Functions - Issues with Logging and Authentication

Kaustubh Kishore 1 Reputation point


So I've been trying to deploy a function app to Azure with Azure Active Directory as a means of authorization since I want it to be accessible by only a few people that are present in my AAD. The function works perfectly till the time Authentication is disabled, but once I enable authentication everything just breaks down. I've been calling my function through postman from where I generate an oauth2 token (which is again working as I want it to work i.e. if a user outside my AAD tries to authenticate then the token is not generated but if the user is part of my AAD then the token is generated which contains the correct details as far as I can tell when I try to read it through a JWT viewer).

Once authentication is enabled, the C# logger that is implemented also breaks down(It posts to AppInsights just fine before authentication is enabled on the function app).

For reference I've been following these steps from an article that I found online to set up the Authorization part( ).

So the debugging process has really hard since all the logging breaks down once the function is deployed over azure and so I went to the Kudu portal of the function app and tried looking for some logs where I found that my ClaimsPrincipal.Identity.Name and ClaimsPrincipal.Identity.Authentication type have been logging correctly since I put this line in my code:

log.LogWarning(principal.Identity.Name + " " + principal.Identity.AuthenticationType + " " + principal.Identity.IsAuthenticated.ToString());

but immediately after this warning log inside kudu logs an error seems to be getting triggered for which an error message is being printed in the kudu logs saying

Value cannot be null. (Parameter 's')

Any help or any nudge in the right direction is appreciated


Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,495 questions
{count} votes