Azure Functon: Azure Monitor captures 401 and Application Insights does not.

Brandon Boone 31 Reputation points
2022-02-17T19:19:38.817+00:00

I'm using Azure functions and Application Insights together (C# .NET Core 3.1). When passing an incorrect function key value, using the x-functions-key header, a 401 is returned as expected, however, this is not logged in Application Insights and only shows in Azure Monitor. All other requests after authentication are logged as expected (500, 200, etc.). As I primarily use Application Insights for setting up alerts and notifications, is there a way to have the 401s logged there as well or will I need to do this separately in Azure Monitor?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,196 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,890 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 21,361 Reputation points
    2022-02-18T10:54:01.953+00:00

    Hi @Brandon Boone ,

    Welcome to Microsoft Q&A! Thanks for posting the question.

    I see that you are trying to get the 401 errors to log in Azure Application Insights to take reactive measures based on it. Please note that 401 (and other 4XX) errors fall under Client error category, i.e., it indicates that the error has occurred, and the client browser/application appears to be at fault (in current case, the client has supplied the incorrect function key).

    In case you would like to track these errors as well, you can use:
    Client Side monitoring, if the request comes from a web page, OR
    ApplicationInsights SDK for tracking them from your application.

    Please let us know if you have any questions.

    ---
    Please 'Accept as answer' if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.