Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
429 stars 184 forks source link

ServiceBusTrigger - ServiceBusSessionMessageActions is null when IsBatched = true #2675

Open JosefBackovsky opened 2 months ago

JosefBackovsky commented 2 months ago

Description

When using an Azure Function with a Service Bus trigger in .NET 8 isolated mode and with session-enabled batching, the ServiceBusSessionMessageActions parameter is unexpectedly null.

Example:

public async Task Run(
    [ServiceBusTrigger("TopicName", 
        "SubscriptionName", 
        Connection = "ServiceBusConnection", 
        IsSessionsEnabled = true, 
        AutoCompleteMessages = false, 
        IsBatched = true)]
    ServiceBusReceivedMessage[] messages,
    ServiceBusMessageActions serviceBusMessageActions,
    ServiceBusSessionMessageActions serviceBusSessionMessageActions,
    CancellationToken cancellationToken)
{
    // serviceBusSessionMessageActions is null when triggered
    ...
}

Issue:

Expected Behavior:

ServiceBusSessionMessageActions should be injected properly even when batching is enabled, allowing session-related actions (e.g., session state management) to be handled within the function.

Actual Behavior:

When IsBatched = true, the serviceBusSessionMessageActions parameter is always null, making it impossible to perform session-related actions in a batched function.

Steps to Reproduce:

  1. Create an Azure Function in .NET 8 isolated mode.
  2. Use a ServiceBusTrigger with the following conditions:
    • Sessions enabled (IsSessionsEnabled = true).
    • Batching enabled (IsBatched = true).
  3. Add ServiceBusSessionMessageActions serviceBusSessionMessageActions as a parameter in the function signature.
  4. Trigger the function with session-enabled messages in the Service Bus.
  5. Observe that serviceBusSessionMessageActions is null when the function is invoked.
JosefBackovsky commented 1 month ago

This issue is blocking our migration to the isolated process. Could you please advise on what steps we should take next or if there is a planned fix?

JosefBackovsky commented 2 weeks ago

It would be good to get at least some information.