我对Azure Application Insight完全陌生,并尝试通过本地计算机发送TrackEvent。但是Azure Application Insight似乎什么也没收到。
这是我的必需品。规格 我的示例asp.net框架控制台代码已安装了应用程序见解sdk nuget,并且已配置Telemetry客户端和Instrumental Id。控制台运行后,Azure应用程序见解应按预期显示历史记录。 但是它什么也没显示。我想念什么吗?
我的简单控制台代码
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = "c453fec7-ea68-4c06-83e4-2938eef1f124";
TelemetryClient telemetry = new TelemetryClient();
telemetry.Context.User.Id = "Test User Id.";
telemetry.Context.User.Id = "Test Device Id.";
telemetry.TrackEvent("Test TrackEvent");
InstrumentationKey是正确的。 Telemetry.TractEvent方法不会公开异常。 Azure Application Insight搜索(用于自定义事件)不显示历史记录。
谢谢。
答案 0 :(得分:4)
原因可能是由于以下原因之一:
2。在控制台代码中,应添加Flush()和sleep()方法。
static void Main(string[] args)
{
TelemetryConfiguration.Active.InstrumentationKey = "your key";
var telemetryClient = new TelemetryClient();
telemetryClient.Context.User.Id = "uid1";
telemetryClient.Context.Device.Id = "did1";
telemetryClient.TrackEvent("AtestEvent7");
telemetryClient.Flush();
System.Threading.Thread.Sleep(5000);
}
顺便说一句,我注意到您在代码中两次定义了telemetry.Context.User.Id
,也许是错字。