Reputation: 88
I am trying to get the message Id of the currently processing message in a Queue in Azure web job. Couldn't find any proper documentation on how to get that.
public static void ProcessQueueMessage([QueueTrigger("%testingQueue%")] TestingMessageModel testMessage, TextWriter log)
{
// want to do some logging for this particular triggered message using the messageid. How to get that?
}
Adding the TestingMessageModel as a reference, it doesn't have any guid. I want to use the GUID that azure creates when a message is put into the queue.
public class TestingMessageModel
{
public int FromOrg {get; set;}
public DateTime BatchDate {get; set;}
public Payments[] payments {get; set;}
}
Upvotes: 3
Views: 2828
Reputation: 2377
The queue trigger provides several metadata properties (including the message id).
These properties can be used as part of binding expressions in other bindings or as parameters in your code:
Upvotes: 3
Reputation: 14334
It supports to bind the id
directly, you could check my code.
public static void ProcessQueueMessage([QueueTrigger("myqueue")] string message,ILogger logger, string id)
{
logger.LogInformation(message);
logger.LogInformation($"{message}id={id}");
}
Hope this could help you.
Upvotes: 8