Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure函数未将自定义事件记录到application insights_C#_Azure_Azure Functions_Azure Application Insights - Fatal编程技术网

C# Azure函数未将自定义事件记录到application insights

C# Azure函数未将自定义事件记录到application insights,c#,azure,azure-functions,azure-application-insights,C#,Azure,Azure Functions,Azure Application Insights,我已经创建了一个服务总线触发的Azure函数,并希望在application insights中记录自定义事件 private static string key = TelemetryConfiguration.Active.InstrumentationKey = System.Environment.GetEnvironmentVariable( "APPINSIGHTS_INSTRUMENTATIONKEY", Environme

我已经创建了一个服务总线触发的Azure函数,并希望在application insights中记录自定义事件

 private static string key = TelemetryConfiguration.Active.InstrumentationKey =
            System.Environment.GetEnvironmentVariable(
                "APPINSIGHTS_INSTRUMENTATIONKEY", EnvironmentVariableTarget.Process);

        private static TelemetryClient telemetryClient =
            new TelemetryClient() { InstrumentationKey = key };

        [FunctionName("Function1")]
        public static void Run([ServiceBusTrigger("xxxxx", "xxxxx", AccessRights.Manage, Connection = "SBConnectionKey")]string mySbMsg, ILogger logger, TraceWriter log)
        {
            log.Info($"C# ServiceBus topic trigger function processed message: {mySbMsg}");

            telemetryClient.Context.Cloud.RoleName = "AIFunction";
            logger.LogMetric("test", 123);

            telemetryClient.TrackEvent("Ack123 Recieved");
            telemetryClient.TrackMetric("Test Metric", DateTime.Now.Millisecond);
       }
我只能看到
log.Info($“C#ServiceBus主题触发函数处理的消息:{mySbMsg}”)此日志记录在跟踪中。但是自定义事件和度量没有记录到application insights。

有什么想法吗?

回答你明确的问题:

我发送的遥测有什么问题,或者在ApplicationInsights门户中的何处可以找到它

我用几乎相同的代码创建了这个函数并进行了测试。你可以分析这些数据。我部署了该函数,并得到以下结果:

回答你隐含的问题:

如何使用应用程序洞察

一开始使用AppInsights查询语言很难,我发现简洁的文件很有帮助。在使用该监控工具时要考虑的其他因素:

  • 发送遥测数据和您在application insights portal中看到的数据之间存在滞后。实时监控将是一个昂贵的工具
  • 在过去,我面临着同样的问题,问题是在遥测的名称中找不到事件/度量名称,而是在细节的某个地方。问题,可能是指它。所以我们决定做的是提供更多的细节以及方法和类的使用
  • 尽管应用程序见解看起来可能令人困惑,但这是一个强大的工具,值得花时间更好地学习

  • 嗨Farrukh Normuradov,谢谢你的详细回答。感谢你的努力。但是您已经使用了HttpTrigger。我看到它正在与之合作,但不与ServiceBusTrigger合作。为了让ServiceBustigger正常工作,我们还需要添加什么吗。Thansk@CGN007,我用服务总线队列触发器对其进行了测试。我将代码添加到。你可以找到结果。我可以证实它是有效的。只需部署我的函数应用程序并对其进行测试。@CGN007您是否有机会尝试我为您准备的内容?我要验证的第一件事是您是否获得了预期的指令插入密钥。它是(1)设置的,并且(2)向您认为它是的资源发送遥测数据。