I have an Azure function that is trigger from a Subscription to an Azure Service Bus Topic. The definition looks as follows:
[Function("logactivity")]
public async Task Run([ServiceBusTrigger("marketplaceactivity", "logactivity", Connection = "ServiceBusConnection")] string mySbMsg,
FunctionContext functionContext)
{
Within this function, I want to send a message to the DeadLetterQueue if it does not pass certain validation. I have seen various answers but I have not been able to find the correct way to do this from within an Azure function triggered by a subscription to a service bus topic. Some solutions have referenced a method on the message object that can send it to the DeadLetterQueue but in my case I don't get a reference to a message. I have also tried looking at the standard properties I get access to including the FunctionContext but again, I don't see a way to get the message to go to the DeadLetterQueue. I have also looked into the Object Explorer in Visual Studio searching for DeadLetterQueue and found a reference to using Azure.Messaging.ServiceBus.ServiceBusReceiver.DeadLetterMessageAsync but I cannot seem to find where I would get access to that function within my Azure Function.
Any ideas / suggests would be greatly appreciated.
You seem to use Isolated Worker Functions SDK. It doesn't support message dispositioning yet. Your best bet for now is to let the retries to be exhausted and the message will be dead-lettered automatically.
There's a public issue related to this topic you can subscribe to.