Last active
September 13, 2022 15:17
-
-
Save ChrisRomp/3d04aaf5b050ab4dc9da01dd1c5d0196 to your computer and use it in GitHub Desktop.
Azure Service Bus AD Auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tenantId = {{$dotenv TENANTID}} | |
@subId = {{$dotenv SUBID}} | |
@clientId = {{$dotenv CLIENTID}} | |
@clientSecret = {{$dotenv CLIENTSECRET}} | |
@sbName = {{$dotenv SBNAME}} | |
@sbUrl = https://{{sbName}}.servicebus.windows.net | |
### | |
# Get OAuth Token | |
# @name getToken | |
POST https://login.microsoft.com/{{tenantId}}/oauth2/token | |
Content-Type: application/x-www-form-urlencoded | |
grant_type=client_credentials | |
&client_id={{clientId}} | |
&client_secret={{clientSecret}} | |
&resource=https%3A%2F%2Fservicebus.azure.net | |
### | |
# Send Message to Topic | |
# https://docs.microsoft.com/en-us/rest/api/servicebus/send-message-to-queue | |
POST {{sbUrl}}/topic1/messages | |
Authorization: Bearer {{getToken.response.body.access_token}} | |
Content-Type: application/json | |
X-Custom-Property1: PropValue1 | |
{ | |
"body": "Hello, World! {{$datetime iso8601}}" | |
} | |
### | |
# Receive/Delete messages from Subscription | |
# @name receiveDelete | |
@timeout = 30 | |
DELETE {{sbUrl}}/topic1/subscriptions/topic1sub1/messages/head?timeout={{timeout}} HTTP/1.1 | |
Authorization: Bearer {{getToken.response.body.access_token}} | |
### | |
# Peek/Lock messages from Subscription | |
# @name peekLock | |
POST {{sbUrl}}/topic1/subscriptions/topic1sub1/messages/head HTTP/1.1 | |
Authorization: Bearer {{getToken.response.body.access_token}} | |
### | |
# Unlock message | |
# @prompt messageId | |
# @prompt lockToken | |
PUT {{sbUrl}}/topic1/subscriptions/topic1sub1/messages/{{messageId}}/{{lockToken}} HTTP/1.1 | |
Authorization: Bearer {{getToken.response.body.access_token}} | |
### | |
# Delete message | |
@messageId = f4e3148fc6de492b882c53c0f34dac03 | |
@lockToken = 772f6c40-84e6-4331-9452-93300d367fdc | |
DELETE {{sbUrl}}/topic1/subscriptions/topic1sub1/messages/{{messageId}}/{{lockToken}} HTTP/1.1 | |
Authorization: Bearer {{getToken.response.body.access_token}} | |
### | |
GET https://{{sbName}}.servicebus.windows.net/$Resources | |
#Authorization: Bearer {{getToken.response.body.access_token}} | |
Accept: application/json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using the VS Code REST Client extension: https://marketplace.visualstudio.com/items?itemName=humao.rest-client