I'm using .net 5 azure function with ServiceBusTrigger. In previous versin. I was using a parametr MessageReceiver to tell azure that I compleated task. For that I used
await messageReceiver.CompleteAsync(message.SystemProperties.LockToken);
My problem is that i new version (.net5) unlike the previous version (.net core 3.1) is param in string (json) not in object (maybe it's the error but I don't know which object to use, object I tried was Microsoft.Azure.ServiceBus.Core.MessageReceiver).
But now i do not have the object so i can not call the method.
Does someone knows the answer? Thak you for your time.
Example of my code:
Function("TasksFunction")]
public async Task Run([ServiceBusTrigger("queue", Connection = "ConnectionString")] string message, string id, MessageReceiver messageReceiver, FunctionContext executionContext)
{
try
{
await messageReceiver.CompleteAsync(message.SystemProperties.LockToken);
await DoWorkAsync(messageReceiver, message);
}
catch (Exception e)
{
log.LogCritical(e);
}
}
Try to bind your message to Message type instead of string
public async Task Run([ServiceBusTrigger("queue", Connection = "ConnectionString")] Message message, string id, MessageReceiver messageReceiver, FunctionContext executionContext)
Message has property SystemPropertiesCollection and use message.SystemProperties.LockToken
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.