question

pavankarnalkar-0370 avatar image
0 Votes"
pavankarnalkar-0370 asked AnuragSingh-MSFT commented

Error handling for wrong instrumentation in azure app Insights

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-monitorazure-app-configuration
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AnuragSingh-MSFT avatar image
0 Votes"
AnuragSingh-MSFT answered AnuragSingh-MSFT commented

Hi @pavankarnalkar-0370

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.

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the answer @AnuragSingh-MSFT. I got your point that we can handle the issue by checking app-insights metrics. But from a better UI and a user perspective, I want to handle this on the UI side like triggering some error message popup.

Is there any API end-point available for instrumentation-key validations? / if we can validate it internally in the app that will be helpful too.

0 Votes 0 ·

Thank you @pavankarnalkar-0370 for the reply. I have reached out to our team internally and will get back to you with an update.

0 Votes 0 ·

Hi Anurag.

Any update from the team?. I'm still in search of a solution.

0 Votes 0 ·
Show more comments