Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

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

Closed
AndreaPic opened this issue Dec 27, 2020 · 5 comments

Comments

@AndreaPic
Copy link

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
Copy link
Collaborator

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

@AndreaPic
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Member

fabiocav commented Dec 30, 2020

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
Copy link

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants