Set Dead letter reason from logic app

Viewed 968

We have a Logic app which peeks a message from both queue and topic, handles the message and then complete the message in case all actions are a success or dead letter the message if an error occurred. To organize our dead letter queue, we want to associate a reason to indicate what error occurred. However the out of the box service bus connector does not seem to have an option to set the dead letter reason.

Does anyone know if it is possible to set the dead letter reason from a Logic App? If yes, please share how this can be done.

On trying to use an Azure function, I went stuck how to pass the BrokeredMessage instance from the logic app to the Azure function. When trying to call I get the options below. Options to pass from Logic App to Azure function

2 Answers

I don't see how I can pass the object from a logic app to the function. I am using the http trigger for the function.

We could pass the object to the body field. The body is depended on what you have implement in the Azure function.

It works correctly on my side. The following is my detail test steps:

1.Create a logic App designed as following

enter image description here

2.Create a HttpTrigger function with following code.

using System.Net;
using System;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    log.Info("C# HTTP trigger function processed a request.");

     dynamic data = await req.Content.ReadAsAsync<object>();
     var messageId =data?.MessageId;
     //To Do
     return req.CreateResponse(HttpStatusCode.OK,"successful!");//return what you wanted
}

3.Send a message to Azure service bus.

4.Check from the Logic App

enter image description here

You can't pass the BrokeredMessage so it seems the best you can do right now is hope you aren't using the deferral feature for anything else, then:

1) Defer the message from the Logic App (Connector: Defer the message in a queue)

2) Call your Azure function and pass it the message SequenceNumber, reason, and description. Within the function you can retrieve the deferred message using the sequence number. Now you have a BrokeredMessage object you can dead-letter with the other information you passed.

Related