One of my favourite tools for testing RESTFul services is Postman. In this blog I will describe how to use this tool for testing an Azure relay service bus. Remember if you are hosting the service in IIS you will need to ensure the service is already warm started. Here is a blog by Jeroen Maes describing how to do this.
First we need to generate the Authorization token as described in this article by Microsoft using the SAS keys Shared Access Signature Authentication with Service Bus
Below is some sample code to create a SAS token to be passed in the request header.
- resourceUri – This is URL of the web service endpoint in Azure, eg (https://mywebservice.servicebus.windows.net/RequestAvailability)
- sasKeyName – The name given to the authorization rule in Azure Service Bus.
- sasKey – The generated SAS key from Azure Service Bus
Calling the GenerateToken() function will return a string value similar to this: SharedAcessSignature sr=https%3a%2f%2fmywebservice.servicebus.windows.net%2fRequestAvailability&sig=UUEIhOkWX3FzrtBsRia9WFeYxbhMQ9FdppmFMjuJv7U%3d&se=1443495583&skn=MyKeyName
Now we can setup the headers for the request in Postman. Add a header called Authorization and set the value to the string returned from the function GenerateToken(). Now you are ready to send your request to the relay service bus.