1

I'm trying to get application insights to work in azure batch job/task while running through a .net core 3.1 console application.

When I run the console app through Visual Studio debug or directly on a node in the batch pool, I get all the appropriate telemetry and logs. However when I setup a task to run the console app I'm not getting any data in application insights.

Guides I looked through:

Is there anyway to get the AppInsights data when running the console app through the task?

edit I have added a TelemetryClient.Flush and Thread.sleep to the end of the process. I can now see explicit calls to TelemetryClient.TrackedEvents but I'm not getting any dependency information, such as SQL call, api calls etc.This only happens to calls made inside a Task. If the console application gets called through a regular command line all information is visible.

Azbami
  • 11
  • 2
  • Does this answer your question? [TelemetryClient produces inconsistent results in Application Insights](https://stackoverflow.com/questions/43791604/telemetryclient-produces-inconsistent-results-in-application-insights) – John Gardner May 08 '20 at 18:55

1 Answers1

0

Probably the issue is that the console app closes before telemetry is sent. you'll need to explicitly call "flush" on the telemetry client/etc and wait some time to allow telemetry to be sent.

see: TelemetryClient produces inconsistent results in Application Insights

John Gardner
  • 24,225
  • 5
  • 58
  • 76
  • This works partially. I can get Event information that I explicitly call but I'm unable to get any dependency telemetry like SQL calls. I'm also uncertain as to why it works perfectly if I run the exact same parameters through command line versus the task. – Azbami May 11 '20 at 20:15