Azure / azure-functions-servicebus-extension

Service Bus extension for Azure Functions
MIT License
65 stars 36 forks source link

IMessageSession parameter not recognized in Azure Function with Service Bus trigger #83

Closed mronnlun closed 4 years ago

mronnlun commented 4 years ago

I have this function

[FunctionName("MyFunction")] public static async Task Run([ServiceBusTrigger("myqueue", Connection = "MyBusConnString", IsSessionsEnabled = true)]Message message, IMessageSession session, ILogger log)

When executing I get this error:

The 'MyFunction' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'MyFunction'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'session' to type IMessageSession. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

I am referencing the following nuget packages: Microsoft.Azure.WebJobs.Extensions.ServiceBus version 4.1.1 Microsoft.NET.Sdk.Functions version 3.0.7

How can I access the session from the function?

peterson1 commented 4 years ago

I'm stuck here as well. Anyone knows how to get IMessageSession from a FunctionApp service bus trigger?

alrod commented 4 years ago

You need to bind to IMessageSession messageSession.

peterson1 commented 4 years ago

I did the same thing as @mronnlun . I thought this was the way to do it, but I got the same error as him. What's the correct way to bind to IMessageSession?

alrod commented 4 years ago

The function parameter name must be messageSession https://github.com/Azure/azure-functions-servicebus-extension/blob/dev/test/Microsoft.Azure.WebJobs.Extensions.ServiceBus.Tests/ServiceBusSessionsEndToEndTests.cs#L397

ghost commented 4 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.