简体   繁体   中英

C# Console Application in VS code not writing in Application Insight

I am trying to log CustomEvents in Application insight using telemetry . The code is a C# Console application and using below code to log Custom Event in Application Insight.

TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault();
configuration.InstrumentationKey = "*************";
var telemetryClient = new TelemetryClient(configuration);
var properties = new Dictionary<string, string> { { "testKey1", "testVal1" }, { "testKey2", "testVal2" } };
telemetryClient.TrackEvent(EventName, properties);  
telemetryClient.Flush();

This code is working fine in Visual Studio 2022 and also logging values in App Insight . But in VS Code it is not pushing any data in App Insight. I am not even getting and error messages in VS Code. Please suggest.

Currently, Application insights is not supported for .NET console application . It supports NodeJS projects only.

That is the reason it not able to send the telemetry information into azure application insights.

在此处输入图像描述

You have to use the Visual Studio for full .NET Project supports.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM