2

How do I add custom Global Telemetry initializer to logs sent to Application Insights from Azure Function Apps?

In Azure App Services I could add them in the Configure section of the Startup.cs

var defaultTelemetryConfig = app.ApplicationServices.GetService<TelemetryConfiguration>();
            defaultTelemetryConfig.TelemetryInitializers.Add(new CustomInitializer());

How do I achieve the same in Azure Function App? I need to add some extra properties to all logs that are being put in App Insights, and this includes the logs which are automatically logged by App Insights (for e.g. Dependency Logs, Unhandled exceptions from Functions, requests, etc.).

JleruOHeP
  • 10,106
  • 3
  • 45
  • 71
Pratik Bhattacharya
  • 3,596
  • 2
  • 32
  • 60
  • There is a tutorial about send custom telemetry data:[Log custom telemetry in C# functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-monitoring#log-custom-telemetry-in-c-functions). Is this what you want? – George Chen Jun 12 '19 at 09:56
  • Not really. I am looking for how to add Telemetry Initializers at a Global level for an Azure Function App. – Pratik Bhattacharya Jun 12 '19 at 09:58
  • @PratikBhattacharya It's an [issue](https://github.com/MicrosoftDocs/azure-docs/issues/23642) I submitted before. And I will check with the guy who is responsible for it. – Ivan Glasenberg Jun 12 '19 at 10:04
  • @IvanYang thanks for the update. I can see your comment in the Github issue as well. – Pratik Bhattacharya Jun 12 '19 at 10:39
  • @PratikBhattacharya, you can check my [answer](https://stackoverflow.com/questions/57073603/adding-custom-dimension-to-request-telemetry-azure-functions?answertab=active#tab-top) in this post and make some changes for your need. – Ivan Glasenberg Jul 18 '19 at 06:52
  • @PratikBhattacharya, I'm here to check if you have solved this issue or not. As of now, it can work at my side. Please let me know if you need it. – Ivan Glasenberg Oct 25 '19 at 06:00

0 Answers0