1
votes

I have several Azure Functions with Queue Triggers. In Version 2

public static void Run(string message, ICollector<string> output, ILogger log) {
  try { DoMyFunction(message, output, log); }
  catch { // HOWTO: Tell Queue Not to Bother Retrying }
}

All onwards Queues are as output collections.

Given a Message that is not supported
When then message is processed by my function
Then my function should return a status that ensures the message is not retried

I am assuming that an HTTP 400 Bad Request is what we're after - therefore I'm looking for the equivalent of

public static HttpStatusCode Run(string message, ICollector<string> output, ILogger log)
{
  try {
    DoMyFunction(message, output, log);
    return HttpStatusCode.OK;
  }
  catch { return HttpStatusCode.BadRequest; }
}
2
From your description I am not sure what your intent is. Maybe this is a solution for you stackoverflow.com/questions/44786141/…Sebastian Achatz
No - This is a response to one specific message only. If the message is invalid - please don't try again. It may be that legal messages fail halfway through and need to be retried.David Lapeš
@DavidLapeš, where would you be returning the HTTP status code in this case? what is your output supposed to be? Note that you can only return an HTTP response to an HTTP requestMarie Hoeger
This is to signal to the ServiceBus that the message is unsupported and should be deadletteredDavid Lapeš

2 Answers

1
votes

If I understand correctly, you should configure you function in host.json and set maxDequeueCount to 1.

1
votes

The messageHandlerOptions in host.json for Service Bus will be useful to you (specifically, autoComplete). Instead of returning an HTTP response, which doesn't make sense in the context of Azure Functions bindings, you can use methods on BrokeredMessage. This stackoverflow post may be helpful, although note that the answer is out of date.

When looking for documentation no this, you should look for information about the Service Bus binding and not "Queue storage" or "Queue Trigger", as these bindings are for Azure Storage queues.