in TimedHostedService class, we have a wrong variable:
telemetryClient.TrackEvent("Bing call event completed");
should be:
_telemetryClient.TrackEvent("Bing call event completed");
NET Core/.NET Framework Console application, if we create a new ConsoleApplication and copy that code, I receive the following error:
System.InvalidOperationException: 'No service for type 'Microsoft.ApplicationInsights.TelemetryClient' has been registered.' for the line:
var telemetryClient = serviceProvider.GetRequiredService<TelemetryClient>();
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Just opened a PR solving the wrong naming and some issues in async/sync method. But, that still doesn't solve the problem with TelemetryClient.
@eddynaka for your .NET Core/.NET Framework application are you testing with the code in this section which is specifically designed for that purpose:
https://docs.microsoft.com/azure/azure-monitor/app/worker-service#net-corenet-framework-console-application
I just re-tested this codeblock in a .NET Core console app and couldn't repro your issue.
I'm trying to figure out what are the differences between my project and the example one. Besides that, the PR just solves some compilation error when I copied / pasted in my project
@eddynaka , I'm going to assign this to the document author so they can get your issue resolved.
Downloading from the GitHub code. Everything is working fine. Probably something here. U can close the issue, since we already solve the problem in the variables in the pr
@eddynaka, thanks again for the fix! Going to close this one out now.