Azure-docs: ApplicationInsights warning - clarification

Created on 19 Feb 2020  Â·  6Comments  Â·  Source: MicrosoftDocs/azure-docs

Do not add AddApplicationInsightsTelemetry() to the services collection as it registers services that conflict with services provided by the environment.

Can this be clarified further? I added a dependency to my code on TelemetryClient but without adding AddApplicationInsightsTelemetry() the injected instance of TelemetryClient was null.

If I add AddApplicationInsightsTelemetry() to my FunctionsStartup class - what exactly is it breaking that the Warning is talking about?


Document Details

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

Pri1 azure-functionsvc cxp product-question triaged

All 6 comments

@oatsoda Thank you for your feedback! We will review and update as appropriate.

@oatsoda The functions runtime already initializes application insights and uses the same for logging/metrics in its own code.

The idea here is to not re-initialize the same and instead use the existing services. If you require, your own TelemetryClient object, you should be able to create one from the injected TelemetryConfiguration as shown in this sample.

@oatsoda Just following up here... Hope my previous comment clears things up.

@oatsoda Hope my previous comment clears things up.

Since we have not heard back from you we will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.

@PramodValavala-MSFT Thanks - yes, it worked perfectly. I am adding AddApplicationInsightsTelemetry() to my startup when running locally in development, but not in Azure.

Adding the dependency on TelemetryConfiguration instead of TelemetryClient works as expected.

Thanks

I added a link to the sample that @PramodValavala-MSFT suggested in the warning box to make it more clear for others that want to do the same.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JamesDLD picture JamesDLD  Â·  3Comments

bdcoder2 picture bdcoder2  Â·  3Comments

paulmarshall picture paulmarshall  Â·  3Comments

mrdfuse picture mrdfuse  Â·  3Comments

varma31 picture varma31  Â·  3Comments