public static async Task Run(
     [ServiceBusTrigger("<queue_name>", Connection = "<connection_name>")]
     ServiceBusReceivedMessage[] messages,
     ServiceBusMessageActions messageActions)
 {
     foreach (ServiceBusReceivedMessage message in messages)
     {
         if (message.MessageId == "1")
         {
             await messageActions.DeadLetterMessageAsync(message);
         }
         else
         {
             await messageActions.CompleteMessageAsync(message);
         }
     }
 }
Example #2
0
        public static async Task Run(
            [ServiceBusTrigger("<queue_name>", Connection = "<connection_name>", IsSessionsEnabled = true)]
            ServiceBusReceivedMessage message,
            ServiceBusMessageActions messageActions,
            ServiceBusReceiveActions receiveActions)
        {
            if (message.MessageId == "1")
            {
                await messageActions.DeadLetterMessageAsync(message);
            }
            else
            {
                await messageActions.CompleteMessageAsync(message);

                // attempt to receive additional messages in this session
                await receiveActions.ReceiveMessagesAsync(maxMessages : 10);
            }
        }