Azure-docs: Some examples don't work

Created on 15 Apr 2020  Â·  7Comments  Â·  Source: MicrosoftDocs/azure-docs

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>();

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Azure-Monitosvc Pri2 application-insightsubsvc assigned-to-author doc-bug triaged

All 7 comments

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.

please-close

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bityob picture bityob  Â·  3Comments

JamesDLD picture JamesDLD  Â·  3Comments

jamesgallagher-ie picture jamesgallagher-ie  Â·  3Comments

ianpowell2017 picture ianpowell2017  Â·  3Comments

Favna picture Favna  Â·  3Comments