Search code examples
c#azureazure-functionsazure-application-insights.net-8.0

Missing operation_Name from app insights logs after creating new .NET 8 Azure Function


I created a new Azure Function with ".NET 8 Isolated" and moved my .NET 6 code over to the new files and noticed that App Insights is no longer logging operation_Name column in App Insights. (Note: when I moved the .NET 6 code over I am upgrading it to .NET 8.) I need this for convenient queries.

I was not able to get host.json or appsettings.json to properly configure the other App Insights settings so I did the configuration in C#:

var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureHostConfiguration(hostConfig =>
{
    [...]
})
.ConfigureServices(services =>
{
    services.AddApplicationInsightsTelemetryWorkerService();
    services.ConfigureFunctionsApplicationInsights();
    services.AddHttpClient();
    [...]
})
.ConfigureLogging(logging =>
{
    logging.Services.Configure<LoggerFilterOptions>(options =>
    {
        LoggerFilterRule defaultRule = options.Rules.FirstOrDefault(rule => rule.ProviderName
            == "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");
        if (defaultRule is not null)
        {
            options.Rules.Remove(defaultRule);
        }
    });
    logging.AddFilter("System.Net.Http.HttpClient", LogLevel.Warning);
})
.Build();

Any idea how I get operation_Name logged? I tried setting IncludeScopes but that made no difference. It looks like this may be a known issue that Microsoft didn't want to address: https://github.com/Azure/azure-functions-dotnet-worker/issues/1124 If there is a solution of manually adding the the operation_Name to each ILogger I'd be willing to do that too.


Solution

  • This appears to be fixed as of now. I believe this was a framework bug.