Debug azure functions


Development process is equally important aspect of a SDLC as testing. Testers and developers often face this issue when it comes to testing azure service bus trigger functions or any non-http trigger functions. In order to test azure service bus trigger function apps before deployment, most of them end up creating temporary http trigger function or push messages directly to the services bus queue/topic. There is nothing wrong with both solutions. They work as well as they can. But these solutions are erroneous and inefficient.

Microsoft provides an out of the box technique to trigger a service bus trigger function app without pushing messages directly to the service bus queue. This is achieved through admin endpoints of a function app. It is easy to and does not require any additional code or infra changes. Following are the steps to do it.

Request flow diagram


1. Note down the service bus trigger name of the function app

Test azure queue trigger

In our case name is onsb-message-received

2. Create a postman collection to send messages to this function. This postman collection will have a Post http method, and url will be something like http://localhost:7071/runtime/webhooks/signalr” Hostname can be used from that url directly.

4. Prepare message for request. The message body should be entirely in string format. If the app accepts a request in json format, then the request needs to be stringified first to be sent from Postman.

azure service bus trigger

The body should be in this format only.

5. Sending request from the Postman.

trigger service

As soon as send is clicked, we get 202 Accepted responses which indicates that request is successfully delivered to endpoint. Note: If you are doing this for the first time request may take 1 minute to trigger function.

6. Put a breakpoint at the code to see the flow.

trigger service

Here you can see the message sent from the Postman is received.

This way, we can easily test non-http triggers easily. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights