Azure / azure-functions-dotnet-worker-preview

MIT License
65 stars 19 forks source link

Error using ServiceBusTrigger and Microsoft.Azure.ServiceBus.Message parameter #22

Closed AndreaPic closed 3 years ago

AndreaPic commented 3 years ago

I've added this function to test ServiceBusTrigger

public static class Function6
    {
        [FunctionName("Function6")]
        public static void Run([ServiceBusTrigger("crashqueue", Connection = "ConnectionStringName")]
                                Microsoft.Azure.ServiceBus.Message message)
        {
            Console.WriteLine(message.MessageId);
        }
    }

When the function is triggered I have the error below (Exception: Unable to convert to Microsoft.Azure.ServiceBus.Message) Please note:

  1. The function has no error when I use string parameter instead of the Microsoft.Azure.ServiceBus.Message type but to upgrade to .Net 5 I need Microsoft.Azure.ServiceBus.Message parameter.
  2. I've added the package Microsoft.Azure.WebJobs.Extensions.ServiceBus 4.1.0

The error is: [2020-12-27T08:59:10.210Z] Executed 'Functions.Function6' (Failed, Id=95ddc7fd-ca9c-4c25-879d-05ab6061db75, Duration=14890ms) [2020-12-27T08:59:10.212Z] System.Private.CoreLib: Exception while executing function: Functions.Function6. System.Private.CoreLib: Result: Failure Exception: Unable to convert to Microsoft.Azure.ServiceBus.Message Stack: at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ConvertParameter(ParameterInfo param, TypedData value, ParameterConverterManager converterManager) in D:\a\1\s\src\DotNetWorker\Invocation\DefaultFunctionExecutor.cs:line 114 [2020-12-27T08:59:10.217Z] at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionExecutionContext context) in D:\a\1\s\src\DotNetWorker\Invocation\DefaultFunctionExecutor.cs:line 60 [2020-12-27T08:59:10.219Z] at Microsoft.Azure.Functions.Worker.FunctionBroker.InvokeAsync(InvocationRequest invocationRequest) in D:\a\1\s\src\DotNetWorker\Broker\FunctionBroker.cs:line 44. [2020-12-27T08:59:10.237Z] Message processing error (Action=UserCallback, ClientId=MessageReceiver1crashqueue, EntityPath=, Endpoint=.servicebus.windows.net) [2020-12-27T08:59:10.239Z] System.Private.CoreLib: Exception while executing function: Functions.Function6. System.Private.CoreLib: Result: Failure Exception: Unable to convert to Microsoft.Azure.ServiceBus.Message Stack: at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ConvertParameter(ParameterInfo param, TypedData value, ParameterConverterManager converterManager) in D:\a\1\s\src\DotNetWorker\Invocation\DefaultFunctionExecutor.cs:line 114 [2020-12-27T08:59:10.242Z] at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionExecutionContext context) in D:\a\1\s\src\DotNetWorker\Invocation\DefaultFunctionExecutor.cs:line 60 [2020-12-27T08:59:10.244Z] at Microsoft.Azure.Functions.Worker.FunctionBroker.InvokeAsync(InvocationRequest invocationRequest) in D:\a\1\s\src\DotNetWorker\Broker\FunctionBroker.cs:line 44. [2020-12-27T08:59:10.283Z] Executed 'Functions.Function6' (Failed, Id=64b73cb1-4916-4b7f-bde7-e5c8cef6f9b2, Duration=14973ms) [2020-12-27T08:59:10.285Z] System.Private.CoreLib: Exception while executing function: Functions.Function6. System.Private.CoreLib:

SeanFeldman commented 3 years ago

Duplicate of #14. Binding to SDK types is not supported.

AndreaPic commented 3 years ago

Duplicate of #14. Binding to SDK types is not supported.

Binding to Message Type in future will be supported ? I've seen that binding to Microsoft.Azure.Functions.Worker.Pipeline.FunctionExecutionContext parameter is working, is it right? For my scenario Microsoft.Azure.ServiceBus.Message parameter is important but can I read Message Metadata (like UserProperties) from it?

Thank you

SeanFeldman commented 3 years ago

Binding to Message Type in future will be supported ?

I'd think so.

For my scenario Microsoft.Azure.ServiceBus.Message parameter is important but can I read Message Metadata (like UserProperties) from it?

A message metadata is part of a message. You can't read one w/o another. Keep in mind, this is a very early preview. Aka not intended for production.

Ideally #14 will be updated when the appropriate bindings are supported. Cheers.

fabiocav commented 3 years ago

Duplicate of #14

The information shared by @SeanFeldman is correct. This is expected with the current version of the worker and support for rich types will come at a later date.

bjorn-jarisch commented 3 years ago

@fabiocav does "at a later date" mean "in the GA version", "in the .NET 5 timeframe", or later? The comments in this repo are not really clear on this.