Azure / azure-functions-durable-extension

Durable Task Framework extension for Azure Functions
MIT License
711 stars 263 forks source link

Class based function error on later versions of Worker.Extensions.DurableTask #2720

Open TheSpid opened 5 months ago

TheSpid commented 5 months ago

I encountered this issue on a project and have created a minimal new function app for reproduction.

While using Microsoft.Azure.Functions.Worker.Extensions.DurableTask on any versions higher than 1.0.2 and utilizing class based functions as described here, calls to DurableTaskClient.ScheduleNewOrchestrationInstanceAsync fails with below message.

Exception: Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")

As mentioned, i created a small repro project which can be found here. I created an azure functions .net 8 project using azurite. I added a DurableOrchestrator azure function and then updated nuget packages and added class based versions of the orchestrator and activity. The result is the error above and an orchestration stuck in pending state. Switching to version 1.0.2 or 1.0.0 makes the class based code work just fine.

Edit: I want to clarify that the code works fine using function based with any version of the nuget package, and also works fine using 1.0.0 or 1.0.2 with class based. It only fails using >1.0.2 and class based.

Edit: I changed the code to use the class based extension methods (don't know why i didn't before). The result is mostly the same. Using 1.1.0 the call to the orchestrator fails with the above message. Using 1.0.0, the call works, but the orchestration status is set to failed with this message:

{ "message": "The function 'HelloCitiesTyped' doesn't exist, is disabled, or is not an orchestrator function. Additional info: The following are the known orchestrator functions: 'RunOrchestrator'.", "details": null }

vaiste commented 5 months ago

I faced the exact same issue with .NET 7 Azure functions, using Microsoft.Azure.Functions.Worker.Extensions.DurableTask v1.1.0 and Microsoft.Azure.Functions.Worker.Sdk v1.16.4 for my class-based orchestrator function. In my case, the issue was resolved when I reverted Microsoft.Azure.Functions.Worker.Sdk back to v1.15.1 (as found at https://github.com/Azure/azure-functions-durable-extension/issues/2668) and referenced Microsoft.DurableTask.Generators in order to initiate the orchestrator with the auto-generated ScheduleNew[orchestrator class name]InstanceAsync method. It may be related.

TheSpid commented 5 months ago

Both code and original post has been updated.

TheSpid commented 5 months ago

Working on a function based project I just accidentally referenced an orchestrator using the wrong name. Using version 1.1.0, i got the same error as above. The exception thrown by 1.1.0 seems to simply wrap and hide the errors encountered in the orchestrator instead of registering it on the orchestration in the storage account. This is mostly guesswork though. Based on this the issue seems to be twofold: 1: Error handling is off 2: Class based orchestrations can not be found.

Adding on to this, i can report that the functions created by the generators does not show up in the console during startup as functions found.

jviau commented 5 months ago

See https://github.com/microsoft/durabletask-dotnet/issues/247

lilyjma commented 4 months ago

@TheSpid - did Jacob's suggestion resolve your issue?

alhell commented 4 months ago

I have tried Jacob's suggestion. It does not error but the activities are not triggered.