Isolated Function handling Service Bus output binding messages on fail

Marijn 6 Reputation points
2022-03-14T15:31:23.573+00:00

Using Isolated Function, with a Service Bus trigger and a Service Bus output binding.

I have been trying to find the answer to whether there is a possibility that the incoming message fails (and will be retried) but the outgoing message is already send.
Which result in duplications in the output queue. I don't know where in the process 'output-binding-return-values' are being handled.

For Service Bus there is transaction scope to make sure both, completion of incoming message and sending outgoing message, are successful. But in the context of Isolated Function it is not possible to implement that.
And sure, Service Bus duplicate detection can catch the duplicates, but I would like to know which scenarios can cause the duplicates.

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
556 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,354 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,436 Reputation points
    2022-03-16T14:32:15.63+00:00

    @Marijn ,

    Thanks for reaching out to Q&A.

    As you have mentioned, the message metadata ( messaging-specific types) is not yet supported in the Isolated function and is only available with in-process functions. So for a Isolated process, I would suggest you to continue using the duplicate detection enabled service bus queue and pass a custom message id to the message.

    Sample JSON message:
    {
    "Id": "69da1afa-a61a-4a8e-921d-ad8263679d4c",
    "Message": "Test message",
    "CreatedDate": "2022-02-15T18:14:24.8770000+07:00"
    }

    The message id can be retrieved by the function app by reading the string message (myQueueItem in below example)

    public static void Run([ServiceBusTrigger("session-queue", Connection = "constring")] string myQueueItem, FunctionContext context)
    {

            var logger = context.GetLogger("Function1");  
              
            logger.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");  
    
            //split the message id   
    
            string[] s=myQueueItem.Split(',');  
            logger.LogInformation(s[0]);  
    
            //your logic based on message id  
        }  
    

    I hope this helps!

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.