Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...