I'm having trouble setting up an Azure Function that reads from ServiceBus. I have a Service Bus Queue created and I'm adding messages with the Service Bus Explorer in Azure Portal. Here is my working function code.
[Function("TestMessageIngester")]
public static async void TestMessageIngester(
[ServiceBusTrigger(queueName:"BatchTests", Connection = "MyServiceBus", IsSessionsEnabled = true)]
string myQueueItem,
string messageId,
string label,
//IMessageSession messageSession,
FunctionContext context)
{
var logger = context.GetLogger("TestMessageIngester");
logger.LogInformation($"TestMessageIngester processed a message");
}
This has no problem reading from the queue. I've had it working for JSON objects as well. However, I'm having an issue getting the session id. When I add MessageSession or IMessageSession, I get this:
Error converting 1 input parameters for Function 'TestMessageIngester': Cannot convert input parameter 'messageSession' to type 'Microsoft.Azure.ServiceBus.IMessageSession' from type 'System.String'.
I've also tried using the ServiceBusReceivedMessage type in Azure.Messaging.ServiceBus as a parameter, but it just comes in as null. The same for Microsoft.Azure.ServiceBus.Message. I'm going off the docs here but feel like I'm missing something, any help would be appreciated.
Edit: I should mention this is .NET 5 Isolated.
Edit2: I'm reading in the GitHub issues that it's not possible to bind to SDK types in .NET 5 Isolated. Still hoping there is some way to get the session id that I've missed.