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.
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?
Select Application Insights in the Azure control panel for your app service, then select Enable. Choose to create a new resource, or select an existing Application Insights resource for this application. When you click OK to create the new resource you will be prompted to Apply monitoring settings.
Application Insights is a feature of Azure Monitor that provides extensible application performance management (APM) and monitoring for live web apps. Developers and DevOps professionals can use Application Insights to: Automatically detect performance anomalies. Help diagnose issues by using powerful analytics tools.
NET Core WebJob to Azure App Service from Visual Studio uses the same tooling as publishing an ASP.NET Core app. In Solution Explorer, right-click the project and select Publish. In the Publish dialog box, select Azure for Target, and then select Next. Select Azure WebJobs for Specific target, and then select Next.
Summary. Azure Functions offers more developer productivity than Azure App Service WebJobs does. It also offers more options for programming languages, development environments, Azure service integration, and pricing. For most scenarios, it's the best choice.
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:
My ApplicationInsights.config
looks like this:
<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
There is also this: Application Insights on Windows Desktop apps, services and worker roles
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With