Error handling for wrong instrumentation in azure app Insights

pavan karnalkar 21 Reputation points
2021-10-25T11:01:50.597+00:00

I'm using Azure app Insight in my app. I want to handle an error case where if we provide the wrong instrumentation key in the appinsights.js file which is used for configuration.
Currently, appInsights doesn't throw any error but only data tracking is disabled and a post request to (https://dc.services.visualstudio.com/v2/track) gets failed with 400 error.

I want to catch this error from react side and display some appropriate message such as "Please Enter correct instrumentation key"

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,328 questions
Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
237 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 21,386 Reputation points
    2021-10-26T06:07:34.637+00:00

    Hi @pavan karnalkar

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

    This is by design that the app insights sdk silently no-ops when given an invalid instrumentation key. One of the ways, to ensure that the configuration is correct, is to view "Live Metrics" which has a delay of 1 seconds after configuring the application. If you see data coming in for the requests made to the application, it will mean that the key is correct.

    I will also reach out to the team and update this thread if I get additional information on this topic. Please let me know if you have any questions.

    ---
    Please 'Accept as answer' and ‘Upvote’ 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.