Blog Post
Logic Apps Standard custom code now supports .NET 10
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)
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!