Reputation: 16239
I have Azure function like below -
[FunctionName("Demo")]
public static void Run([ServiceBusTrigger("%Demo-Queue%", Connection = "AzureWebJobsBPGAServiceBus")]string myQueueItem,
[ServiceBus("%Update-Queue%", Connection = "AzureWebJobsBPGAServiceBus")] ICollector<BrokeredMessage> updateMessage,
TraceWriter log)
{
string query = "SELECT Id FROM MyTable";
var data = dbs.GetData(query).GetAwaiter().GetResult();
BrokeredMessage brokeredMessage;
foreach (var item in data)
{
JObject jObject = new JObject(new JProperty("Id", item), new JProperty("MessageId", new Guid(item)));
brokeredMessage = new BrokeredMessage(jObject.ToString());
updateMessage.Add(brokeredMessage);
}
}
But message going in dead letter queue . why ? Message format is also correct.Any clue ?
Upvotes: 1
Views: 1806
Reputation: 2474
Your Function is being triggered by messages in your Demo-Queue
and the message(s) myQueueItem
was/were dispatched to your Function Demo
at least 10 times before being moved to the dead-letter queue. Failing >=10 times means that your Function execution did not succeed for >= 10 times.
Kindly search your Function Logs to see if there are any error messages to indicate why your Function execution did not succeed, e.g. due to timeout or errors in your Function code. If it's due to timeout, you may change the autoRenewTimeout
property in your host.json to see if that will resolve the issue.
Note that if you are on consumption plan, the autoRenewTimeout
needs to stay within the constraints of the max execution time of 5 mins (default) or the configured functionTimeout
property (honored to max of 10 mins) in your host.json
file.
Upvotes: 0
Reputation: 1494
If a message is moved to dead-letter Queue, the reason may be one of these. There will be two custom properties added to the dead-letter messages, when it is moved to dead-letter Queue (DeadLetterReason and DeadLetterErrorDescription), try reading those properties to find the reason.
Upvotes: 2