microsoft / microsoft/durabletask-mssql

Durable Entity creates NullReferenceException with Microsoft.Azure.Functions.Worker.Extensions.DurableTask.SqlServer

Open
#205 15 comments 0 reactions 1 assignee View on GitHub

@andystaples is already working on this.

Since Oct 15, 2025.

enhancement external P1
Dominant language
C#
Stars
105
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Hi.

I have slight problem. Dont know if it a configuration issue on my side or something else.

Currently migrating our software from ..NET6 -> .NET8 and from InProc to Isolated. All good works as intended. The Null Reference Exception shows its self when I switch from AzureStorage to SQL Server.

A bit of code to exemplify the issue.

[Function(nameof(ProcessData))]
 public async Task RunOrchestrator(
     [OrchestrationTrigger] TaskOrchestrationContext context)
 {
     ILogger logger = context.CreateReplaySafeLogger(nameof(ProcessData));
     var input = context.GetInput<string>();


     var result = await context.CallActivityAsync<RegionMix>("ActProcessData", input);

     var countryKey = string.IsNullOrEmpty(result.CountryCode) ? result.Country : result.CountryCode;
     await context.Entities.SignalEntityAsync(new EntityInstanceId(nameof(Entities.EnergyMix), countryKey), "Add", result);


 }

var result is a POCO.
Running this code, I get the NullReferenceException on SignalEntify.

My config is:
Microsoft.Azure.Functions.Worker - 1.20.1
Microsoft.Azure.Functions.Worker.Extensions.DurableTask - 1.1.0
Microsoft.Azure.Functions.Worker.Extensions.DurableTask.SqlServer - 1.2.2
Microsoft.Azure.Functions.Worker.Sdk - 1.16.4

host.json :)

{
  "version": "2.0",
  "extensions": {
    "http": {
      "routePrefix": ""
    },
    "durableTask": {
      "hubName": "%TaskHubConfig%",
      "storageProvider": {
        "type": "mssql",
        "connectionStringName": "Durable_SQLDB_Connection",
        "createDatabaseIfNotExists": true
      }
    }
  },
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      },
      "enableLiveMetricsFilters": true
    },
    "logLevel": {
      "default": "Information",
      "DurableTask.SqlServer": "Debug",
      "DurableTask.Core": "Debug"
    }
  }
}

After a bit of debugging.
The exception originates OrchestrationEntityContext class on DurableTask.Core

 internal void AdjustOutgoingMessage(string instanceId, RequestMessage requestMessage, DateTime? cappedTime, out string eventName)
 {
     if (cappedTime.HasValue)
     {
         eventName = EntityMessageEventNames.ScheduledRequestMessageEventName(cappedTime.Value);
     }
     else
     {
         this.messageSorter.LabelOutgoingMessage(
             requestMessage,
             instanceId,
             this.innerContext.CurrentUtcDateTime,
             this.innerContext.EntityParameters.EntityMessageReorderWindow);

         eventName = EntityMessageEventNames.RequestMessageEventName;
     }
 }

The this.innerContext.EntityParameters is not populated and is NULL.

Is this intentionally? If yes, how do I fix it...

//Daniel

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.