I'm able to send message to Main from Deadletter using below code but issue is unable to complete that message.
error at this line - await
deadletterReceiver.CompleteAsync(newMessage.SystemProperties.LockToken);
System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.Azure.ServiceBus.Message.SystemPropertiesCollection.ThrowIfNotReceived() at Microsoft.Azure.ServiceBus.Message.SystemPropertiesCollection.get_LockToken()
publicstatic async System.Threading.Tasks.TaskRunAsync([TimerTrigger("0 */2 * * * *")]TimerInfo myTimer,ILogger log){
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");try{var deadQueuePath =EntityNameHelper.FormatDeadLetterPath("demo/subscriptions/demo");MessageReceiver deadletterReceiver =newMessageReceiver(Environment.GetEnvironmentVariable("ConnectionStringSettingName"), deadQueuePath,ReceiveMode.PeekLock,RetryPolicy.Default);MessageSender sender =newMessageSender(Environment.GetEnvironmentVariable("ConnectionStringSettingName"),"demo",RetryPolicy.Default);var deadLetter = await deadletterReceiver.ReceiveAsync();if(deadLetter !=null){
log.LogInformation($"got new message");Message newMessage =newMessage(deadLetter.Body){ContentType= deadLetter.ContentType,CorrelationId= deadLetter.CorrelationId};//Send the message to the Active Queue
await sender.SendAsync(newMessage);
await deadletterReceiver.CompleteAsync(newMessage.SystemProperties.LockToken);//Unlock the message and remove it from the DLQ
log.LogInformation($"Unlock the message and remove it from the DLQ");}}catch(Exception ex){
log.LogInformation($"Exception: {ex}");}}