ShawnC
ShawnC

Reputation: 21

How to read Azure Service Bus subscription with HTTP

I'm trying to use Azure Service Bus topics and subscriptions strictly using REST with Shared Access Signature (SAS) as the authentication method. When using Service Bus queues, I can both send and receive a message as a REST API, and when I create a topic, I can send a message to it using that same method. However, I can't figure out the process for reading the message via a subscription using the same approach, and all the examples I've found so far are all using the Service Bus libraries, not as a simple REST API.

My question is whether you can use the REST API model for reading from Service Bus subscriptions. If so, is there a Microsoft article which describes how that works?

What I've tried is using the URI for the topic when generating the SAS and, like with the queue, trying to read the message with the DELETE method:

curl -X DELETE -H "Authorization: $SAS" https://<redacted>.servicebus.windows.net/mytopic/messages/head
<Error><Code>400</Code><Detail>The specified HTTP verb (DELETE) is not valid. To know more visit https://aka.ms/sbResourceMgrExceptions. . TrackingId:f2f08774-ea08-4346-ac95-45f5d20cbcea_G23, SystemTracker:<redacted>:Topic:mytopic, Timestamp:2024-02-27T12:49:54</Detail></Error>%  

I would have expected that if you can write to a topic with REST, you should also be able to read from an associated subscription with the same approach.

Upvotes: 1

Views: 1068

Answers (1)

ShawnC
ShawnC

Reputation: 21

The comment by Jesse Squire above is the answer ... you need to indicate both the topic and a subscription in the URL to read a message from a Service Bus topic using HTTP.

Upvotes: 0

Related Questions