0

Am planning to develop an powershell script to delete DLQ messages under Azure servicebus topic subscription, however i could not find any powershell cmdlet to delete the DLQ messages and when i referred some documents it says its not possible to delete the DLQ messages via powershell as it doesnt have any right cmdlet to delete it , so i tried lets try with Restapi method but i couldnt find accurate restapi. So I have these question

  1. Can i use powershell script to delete dlq messages? or
  2. Which Restapi can i use for it .

Any suggestion on this is much apprciated. Am eager to write powershell scriot but want to know is it possible ? Please note : Am not expert in ps script but i write some basic scripts

Thanks in Advace

Arun Kumar
  • 125
  • 1
  • 2
  • 6
  • You'll need to **receive** and delete those, not delete. Both PowerShell and REST are good options. – Sean Feldman Aug 18 '23 at 15:58
  • @SeanFeldman sorry didnt get your point. Could you please brief a bit. – Arun Kumar Aug 18 '23 at 16:06
  • Messages can be received in two modes. One is a [destructive read](https://learn.microsoft.com/en-us/rest/api/servicebus/receive-and-delete-message-destructive-read), where a message is read and immediately removed from the broker. If you ignore the contents of the read message, that's, in essence, a purge. That can be done with PowerShell. REST API offers a [delete option](https://learn.microsoft.com/en-us/rest/api/servicebus/delete-message). – Sean Feldman Aug 18 '23 at 18:35

1 Answers1

0

Can I use PowerShell script to delete dlq messages?

There is no possibility of using PowerShell script to delete dql messages.

Refer Microsoft Q&A for detailed information on the above approach.

Which Restapi can I use for it?

You can use the Rest API with URL https://<serviceNamespace>.servicebus.windows.net/<queuePath>/messages/head for Delete request as given in the MS Doc.

Or

You can also use service bus explorer under Azure service bus from the Portal as shown.

enter image description here

Refer SO by @Thili for another approach which is using service bus explorer tool to deleted dlq messages.

Jahnavi
  • 3,076
  • 1
  • 3
  • 10