azureazure-functionsazure-application-insightsazureservicebus

Azure Functions & Application Insights requests "Operation Link" empty


We upgraded Azure Functions to Isolated and .NET 8. After doing so we are seeing Service Bus requests in Application Insights having the request property "Operation links" being basically empty

Operation links [{"operation_Id":"00000000000000000000000000000000","id":"0000000000000000"}]

This seems to result that in the end-to-end transaction view multiple requests are thrown together App Insights showing upstream operation having default guid

Application Insights showing request with operation link having default guids

App Insights showing end to end transaction view - having multiple requests and operation ids which should not be there

In our Function we are configuring application insights the following program.cs

.ConfigureServices((context, services) =>
{
    services.AddApplicationInsightsTelemetryWorkerService();
    services.ConfigureFunctionsApplicationInsights();
    services.Configure<LoggerFilterOptions>(options =>
    {
        // The Application Insights SDK adds a default logging filter that instructs ILogger to capture only Warning and more severe logs. Application Insights requires an explicit override.
        // Log levels can also be configured using appsettings.json. For more information, see https://learn.microsoft.com/en-us/azure/azure-monitor/app/worker-service#ilogger-logs
        LoggerFilterRule? ruleToRemove = options.Rules.FirstOrDefault(rule => rule.ProviderName == "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");

        if (ruleToRemove is not null)
        {
            options.Rules.Remove(ruleToRemove);
        }
    });
 }

I would expect that I should only see one Request to Azure Service Bus. Cause this was the case with .NET 6 and in-process

Edit included .csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enabled</ImplicitUsings>
    <AnalysisLevel>latest-recommended</AnalysisLevel>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Analyzers" Version="1.0.0" />
    <PackageReference Include="Azure.Data.Tables" Version="12.9.1" />
    <PackageReference Include="Azure.Storage.Blobs" Version="12.22.1" />
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.4.0" />
    <PackageReference Include="Microsoft.Azure.NotificationHubs" Version="4.2.0" />
    <PackageReference Include="NetTopologySuite" Version="2.5.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.18.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.22.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
  </ItemGroup>
  <ItemGroup>
    <None Include="local.settings.json" />
  </ItemGroup>
</Project>

Solution

  • This issue was caused by an older Application Insights SDK on the API sending in the messages.

    As the model of the in-process functions is different than the isolated functions. Digging way deeper down in the logs, showed that whenever the parent id started with "|" the operation link turned out to be set to 00000... Table view of the log entries

    So whenever there was a "|" in the parent id, the function completely jacked up the operational link.

    Updating to the latest SDK on the API solves this issue.