Search code examples
visual-studioazure-application-insights

Connect web app to Visual Studio Application Insights



I'm using Application Insights as part of my .Net Framework WebAPI project. When running the code locally (in debug mode), I can see all the events that would be sent to AI locally in Visual Studio by clicking the Application Insights button in the toolbar.

I've also got a Angular web App which works in tandem with the .Net backend. I've got the web version of Application Insights setup on it which sends telemetry to an Azure AI instance. Is it possible to have the Angular web app send its telemetry to the local AI instance in Visual Studio when I'm running it locally?

I'm using v2.5.10 of the @microsoft/applicationinsights-web library and Visual Studio Professional 2019 if that makes a difference.


Solution

  • Actually, there is no local AI instance. By default, the data you see in visual studio -> Application Insights Search window is from the current debug session, the screenshot is as below:

    enter image description here

    Another thing is that if you specify a valid InstrumentationKey, the data are always sending to application insights in azure portal(unless you setup firewall rule to block them).

    For Angular web App, there is no way to just show the data in visual studio, but not sending to AI instance in azure.

    Here are some suggestions just for your reference, but they cannot totally meet your requirement:

    Solution 1: Sending data from Angular web App to AI instance in azure, then you can fetch these data from azure to visual studio locally. To do that, in the visual studio -> Application Insights Search window, change the Debug session telemetry to the AI instance in azure. Like below:

    enter image description here

    Solution 2: If you just don't want to send the data to Azure, you can use an invalid InstrumentationKey, and then open tools like fiddler to see these telemetry data.