Blog Post
Logic Apps Standard custom code now supports .NET 10
Hi WSilveira
Not sure if this is a bug, but I'm running into another issue.
I've created a couple of functions in https://github.com/ronaldbosma/track-availability-in-app-insights/blob/main/src/logicApp/Functions/AvailabilityTestFunctions.cs that I use to track availability in Application Insights. In the code, I create a new Activity in the TrackAvailability method, which under the hood relies on Activity.Current.
Before my upgrade, my workflow logging and the availability telemetry were correlated in Application Insights. Here's a screenshot with the availability telemetry at the bottom: https://ronaldbosma.github.io/images/track-availability-in-app-insights-series/track-availability-in-app-insights-using-logic-app-workflow/logic-app-workflow-end-to-end-transaction-details.png
After upgrading to .NET 10, the availability telemetry is no longer correlated with the workflow logging. (Traces when using _logger.LogInformation are still correlated.)
I've added the following to the `TrackAvailability` method:
Activity currentActivity = Activity.Current;
_logger.LogInformation(
"Current Activity Static: Id={Id}, IdFormat={IdFormat}, " +
"TraceId={TraceId}, SpanId={SpanId}, ParentSpanId={ParentSpanId}",
currentActivity?.Id,
currentActivity?.IdFormat,
currentActivity?.TraceId,
currentActivity?.SpanId,
currentActivity?.ParentSpanId);
This is logged in .NET 8:
Severity level: Information, Message: Current Activity Static: Id=00-83fc6659fbfc9f475575d0f73c7b70d7-3e208e36e4d0b070-00, IdFormat=W3C, TraceId=83fc6659fbfc9f475575d0f73c7b70d7, SpanId=3e208e36e4d0b070, ParentSpanId=0000000000000000
This is logged in .NET 10:
Severity level: Information, Message: Current Activity Static: Id=(null), IdFormat=(null), TraceId=(null), SpanId=(null), ParentSpanId=(null)
Activity.Current is null after the upgrade to .NET 10. Is this a bug/regression or do I have to correlate my availability telemetry another way in my Logic App?
Hi Ronald,
Thanks for the details. I can reproduce this with a .NET 10 custom code project, and I've found the cause and a workaround.
Why Activity.Current is null
On .NET 8, your code had an active Activity when it ran. On .NET 10, custom code runs in an isolated worker. That worker creates a per-call Invoke activity, linked to the workflow's trace context, only when an ActivityListener is subscribed to the Microsoft.Azure.Functions.Worker source. Nothing subscribes by default, so Activity.Current is null. Your new Activity("AvailabilityContext") then starts a new trace, and the availability telemetry isn't correlated with the workflow.
_logger.LogInformation traces are still correlated because the logger gets its context from the host through a different path.
Workaround
Register a listener in your existing Startup.Configure :
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace Contoso.Utils
{
using System;
using System.Diagnostics;
using Microsoft.Azure.Functions.Extensions.Workflows;
using Microsoft.Extensions.DependencyInjection;
/// <summary>
/// Configures services for the custom code worker.
/// </summary>
public class Startup : IConfigureStartup
{
public const string EnableActivityListenerSetting = "CUSTOMCODE_ENABLE_WORKER_ACTIVITY_LISTENER";
private static ActivityListener workerActivityListener;
public static bool WorkerActivityListenerEnabled => workerActivityListener != null;
public void Configure(IServiceCollection services)
{
if (!string.Equals(Environment.GetEnvironmentVariable(EnableActivityListenerSetting), "true", StringComparison.OrdinalIgnoreCase))
{
return;
}
// The isolated worker only creates its per-invocation "Invoke" Activity (parented to the host's
// traceparent) when a listener subscribes to its ActivitySource; otherwise Activity.Current is null.
workerActivityListener = new ActivityListener
{
ShouldListenTo = source => source.Name.StartsWith("Microsoft.Azure.Functions.Worker", StringComparison.Ordinal),
Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
};
ActivitySource.AddActivityListener(workerActivityListener);
}
}
}
I've added a sample here: wsilveiranz/custom-code-exception-tracking-samples
Keep the listener in a static field so it stays alive for the life of the worker. You don't need to change TrackAvailability : your new Activity(...) picks up Activity.Current as its parent again.
With the listener registered, I get this locally on .NET 10:
- Activity.Current.Id = 00-d96b925068c2b790ad0b7521810212ec-a261a4014efb3812-00
- Activity.Current.ParentId = 00-d96b925068c2b790ad0b7521810212ec-34d5ba0f94942b0f-00
- Source / OperationName = Microsoft.Azure.Functions.Worker / Invoke
Your availability activity then gets the same trace ID as the workflow call, and that ID becomes the operation ID in Application Insights.
Two notes
• Don't try to read the trace context from a FunctionContext parameter. In custom code it fails with an InvalidCastException because your assembly is loaded in an isolated assembly load context.
• I've confirmed that Activity.Current is set and carries the workflow's trace ID. I haven't yet confirmed in Application Insights that the end-to-end transaction view shows the availability record. I'm testing that in Azure now. If you try it first, let me know what you see.
I'm also raising with the team whether the worker should do this by default, so custom code gets the same behaviour it had on .NET 8.
Cheers,
Wagner (with the useful help of Copilot)
- ronaldbosmaNov 11, 2026Brass Contributor
Hi WSilveira.
It works and I've verified that the end-to-end transaction view in App Insights shows the availability telemetry and workflow logging together.
Thanks again for the help,
Ronald
I'm getting a 404 Not Found on https://github.com/wsilveiranz/custom-code-exception-tracking-samples by the way.- WSilveiraNov 12, 2026
Microsoft
It was a private repo - my bad, mate!