Azure / azure-service-bus

☁️ Azure Service Bus service issue tracking and samples
https://azure.microsoft.com/services/service-bus
MIT License
585 stars 781 forks source link

Deserialization of ServiceBusReceivedMessage fails when sending as input of orchestrator function #559

Closed PauloSRH closed 2 years ago

PauloSRH commented 2 years ago

Description

When sending as a input to the Orchestrator function an ServiceBusReceivedMessage object the deserialization fails with the following code:

namespace Functions.ExampleFunction
{
    using System.Threading.Tasks;
    using Azure.Messaging.ServiceBus;
    using Microsoft.Azure.WebJobs;
    using Microsoft.Azure.WebJobs.Extensions.DurableTask;

    public class ExampleFunction
    {
        [FunctionName(nameof(ExampleFunction))]
        public async Task Run(
            [ServiceBusTrigger("%ServiceBusTopicName%", "%ServiceBusSubscriptionName%", Connection = "ServiceBusConnectionString")] ServiceBusReceivedMessage serviceBusMessage,
            [DurableClient] IDurableOrchestrationClient starter)
        {
            await starter.StartNewAsync(nameof(ExampleOrchestratorFunction), input: serviceBusMessage);
        }
    }
}
...
        protected async Task RunOrchestration(IDurableOrchestrationContext context)
        {
            ServiceBusReceivedMessage serviceBusMessage = context.GetInput<ServiceBusReceivedMessage>();

            ...
        }

Actual Behavior

The received object in the RunOrchestration method appears like this: image

Instead of the expected behavior

Expected Behavior

The received object should be like this: error2

Is this a issue in the deserialization of the class ServiceBusReceivedMessage? Or is something wrong with this code?

EldertGrootenboer commented 2 years ago

As this is a question pertaining to Azure Functions, we would recommend opening an issue on their repository.