Skip to content

Add Support to Allow Message Abandoning and Message Dead Lettering in Azure Functions Service Bus Bindings #1659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trin94 opened this issue Mar 31, 2025 · 1 comment

Comments

@trin94
Copy link

trin94 commented Mar 31, 2025

Binding Type

existing binding (azure.functions.ServiceBusMessage)

Expected Behavior

it's possible to abandon or dead letter messages (without retrying)

Relevant sample code snipped

I've tried putting messages onto the dead letter queue manually, but that did not work:

import azure.functions as func
import logging

app = func.FunctionApp()


@app.function_name(name="process-my-data")
@app.service_bus_queue_trigger(
    arg_name="msg",
    queue_name="sbq-process-my-data",
    connection="MyConnection",
)
@app.service_bus_queue_output(
    arg_name="message",
    connection="MyConnection",
    queue_name="sbq-process-my-data/$deadletterqueue",
)
def process_my_data(msg: func.ServiceBusMessage, message: func.Out[str]):
    logger = logging.getLogger(__name__)
    logger.error("writing onto dlq")
    message.set(msg.get_body())
    logger.error("writing onto dlq done")

If I change message.set(msg.get_body()) to raise ValueError(), then messages are moved to the dead letter queue (after retrying which we don't want).

Additional Information

  • It would be nice if the azure.functions service bus bindings add support (and documentation) for operations like abandoning and dead lettering.
  • The azure.servicebus module allows to do these advanced operations:
    with (
        ServiceBusClient.from_connection_string(connection_string, logging_enable=True) as client,
        client.get_queue_receiver(queue_name) as receiver,
    ):
        receiver.dead_letter_message(...)
    Maybe it is possible using azure.functions and azure.servicebus modules together?
    If so, adding documentation and examples would really help.
  • It only works in C# ?
  • In general, stating in the documentation which functionality is supported in which language would help as well.

Links:

Edit:
Batch processing is kinda impossible without being able to control what happens to individual messages. Without fine grained control we only have the option to retry the entire batch if something fails or not retry at all 😢

@trin94 trin94 changed the title Add Support to Allow Messages Abandoning and Messages Dead Lettering in Azure Functions Service Bus Bindings Add Support to Allow Message Abandoning and Message Dead Lettering in Azure Functions Service Bus Bindings Mar 31, 2025
@vrdmr
Copy link
Member

vrdmr commented Apr 7, 2025

Hi @trin94 - We are working on SDK bindings for Service Bus (similar to the ones like Blobs), which will enable devs to do these updates.

We'll have more updates by next month but the current draft is available at feat: support ServiceBus SDK-type bindings, that'll target #1172 for now and more updates coming up.

It would be nice if the azure.functions service bus bindings add support (and documentation) for operations like abandoning and dead lettering.

Our goal is get the feature set eventually match the ones provided by ServiceBusMessageActions in C#.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants