Skip to content

How to get AppInsights working in .NET 8 Functions v4 #1182

@LockTar

Description

@LockTar

Hi,

Sorry for the new issue but I think this will bring a lot of open issues together to a final solution in a sample repository.
Hopefully we can make something default/officially/easier for new people because it took me a long time to figure everything out.

  • This setup is ugly but solves AppInsights logging in Azure Functions v4 in combination with .NET 7. It uses the new (still in preview) Microsoft.Azure.Functions.Worker.ApplicationInsights package explained in PR 944
  • It fixes the hardcoded Warning filter explained in 1123 comment. See auto added Warning filter details here.
  • It highlights that the default Warning filter is automatically added explained here.
  • It adds an appsettings.json configuration file for default configuration as suggested in Update samples and docs to add Host.CreateDefaultBuilder() #1025
  • It loads the appsettings.json configuration file.
  • It configures the logging from out of the appsettings.json configuration file
  • It is a more realistic sample application other than "Hello world" because of multiple classes, loggers and injected loggers.

I want to thank @brettsam, @jviau and @kshyju for posting helpful comments that let me finally see some logging in Azure Application Insights lower than Warning (so Trace, Debug, Information).

See the sample repository for more details to get it running. See the details of the Func.Isolated.Net7.With.AI project.

Screenshots from Azure:
image
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions