当您在App Insights中打开实时指标时,出现“不可用:您的应用程序脱机或使用较旧的SDK”的提示,通常是由以下原因导致的:
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
public class App
{
private static TelemetryClient telemetryClient;
public static void Main(string[] args)
{
var config = TelemetryConfiguration.CreateDefault();
config.InstrumentationKey = "YOUR_INSTRUMENTATION_KEY";
telemetryClient = new TelemetryClient(config);
// Track an event
telemetryClient.TrackEvent("Application Started");
// Ensure to flush the telemetry before exiting
telemetryClient.Flush();
}
}
通过以上步骤,您应该能够解决“不可用:您的应用程序脱机或使用较旧的SDK”的问题。如果问题仍然存在,请检查应用程序日志和网络日志,以获取更多详细的错误信息。
领取专属 10元无门槛券
手把手带您无忧上云