使用天青与WebJob Azure应用程序洞察 [英] Use Azure Application Insights with Azure WebJob

查看:201
本文介绍了使用天青与WebJob Azure应用程序洞察的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure的文档,包括Azure应用程序洞察整合到不同的应用类型,如ASP.NET,Java等不过,文件没有显示集成应用洞察天青WebJob任何案例的例子很多。

The Azure documentation covers many examples of integrating Azure Application Insights into different applications types, such as ASP.NET, Java, etc. However, the documentation doesn't show any examples of integrating Application Insights into a Azure WebJob.

有没有人有链接到包括如何Azure应用程序洞察整合到公司建成一个控制台应用程序?

Does anyone have link to an example or article that covers how to integrate Azure Application Insights into an Azure WebJob that's built as a Console App?

推荐答案

我写了通过应用程序跟踪洞察事件和度量一个控制台应用程序,而我统计了WebJob不会是所有的不同,加入以下的NuGet包:

I have written a console application that tracks events and metrics via Application Insights, and I figure a WebJob won't be all that different, by adding the following NuGet packages:


  • Microsoft.ApplicationInsights

  • Microsoft.ApplicationInsights.TraceListener(这可以不需要)

我的 ApplicationInsights.config 是这样的:

<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
    <TelemetryModules>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule, Microsoft.ApplicationInsights" />
    </TelemetryModules>
</ApplicationInsights>

和简单的程序做这样的:

And the simple program does this:

TelemetryConfiguration.Active.InstrumentationKey = "the_key";
TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true;

var tc = new TelemetryClient();
tc.TrackRequest("Track Some Request", DateTimeOffset.UtcNow, new TimeSpan(0, 0, 3), "200", true);
tc.TrackMetric("XYZ Metric", 100);
tc.TrackEvent("Tracked Event");

tc.Flush(); //need to do this, otherwise if the app exits the telemetry data won't be sent

还有这样的:<一href=\"https://azure.microsoft.com/en-us/documentation/articles/app-insights-windows-desktop/\">Application在Windows桌面应用程序,服务和辅助角色的见解

这篇关于使用天青与WebJob Azure应用程序洞察的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆