The Azure API Management (APIM) team has released a new feature that makes integration with Azure Service Bus easier than ever — the Send-Service-Bus-Message policy. This powerful addition allows developers to send messages directly from an API call to a Service Bus queue or topic, without writing additional backend code.  Note this is currently in public preview.  

In this post, you’ll walk through how to configure, secure, and test this new policy step-by-step using Azure Portal, Postman, and Service Bus.

YouTube player

Why This New APIM Policy Matters

Traditionally, sending a message from an API to a Service Bus required custom logic or intermediate components like Azure Functions or Logic Apps. The new Send-Service-Bus-Message policy changes that.

With this feature, you can now:

  • Streamline message-based workflows directly within APIM

  • Reduce latency by eliminating extra services

  • Simplify architecture for event-driven solutions

  • Leverage Managed Identities for secure authentication

  • Improve visibility by keeping message flow within your API pipeline

  • Add custom properties to messages before sending to a Queue or Topic

For integration architects and developers, this means faster development and fewer moving parts to maintain.


Prerequisites

Before getting started, make sure you have:

  • An Azure API Management (APIM) instance

  • An Azure Service Bus namespace with at least one queue

  • Proper permissions to assign Managed Identities and policies

  • Postman or any API testing tool for validation


Step 1: Set Up Managed Identity in APIM

  1. Open your Azure API Management instance in the Azure portal.

  2. Go to the Identity blade and enable System Assigned Managed Identity.

  3. Once enabled, Azure will automatically register a Managed Identity for your APIM instance.

This identity allows APIM to securely access other Azure services without storing credentials.

APIM Managed Identities

APIM Managed Identities


Step 2: Assign Permissions on the Service Bus Queue

Next, give APIM’s Managed Identity permission to send messages to your queue:

  1. Navigate to your Service Bus namespace.

  2. Select Access Control (IAM).

  3. Add a new role assignment for the APIM Managed Identity.

  4. Choose the role Azure Service Bus Data Sender and apply it.

This ensures that your APIM instance can send messages to the queue using secure, role-based access.


Step 3: Create or Update Your API in APIM

  1. In the Azure portal, go to your APIM instance.

  2. Open APIs and select the one where you want to apply the new policy.

  3. You can use an existing API or create a new one to test this setup.

Create New APIM

Create New APIM


Step 4: Add the Send-Service-Bus-Message Policy

Inside your API’s Inbound Policy, insert the Send-Service-Bus-Message policy. Here’s an example snippet

Send-Service-Bus-Message Policy

<send-service-bus-message queue-name="QueueName" namespace="NameSpace.servicebus.windows.net">
	<payload>@(context.Request.Body.As<string>(preserveContent: true))</payload>
</send-service-bus-message>
<return-response>
	<set-status code="201" reason="Created" />
</return-response>

This configuration instructs APIM to send a message directly to the Service Bus queue whenever this API endpoint is triggered.


Step 5: Test in Postman

  1. Copy your API’s base URL and subscription key from APIM.

  2. Open Postman and create a new request to your API endpoint.

  3. Add the Ocp-Apim-Subscription-Key header with your key.

  4. Send the request and check the response.

If configured correctly, you should see a success message indicating that the request has been processed.


Step 6: Verify Messages in Azure Service Bus

  1. Open your Service Bus Queue in the Azure portal.

  2. Under Overview, you should now see one or more active messages.

  3. You can use Service Bus Explorer to inspect the message body and confirm that it was sent from APIM.


Troubleshooting Tips

  • If messages don’t appear, verify the Managed Identity has the correct Data Sender role.

  • Check that your namespace and queue names are correctly referenced in the policy.

  • Make sure your API call is reaching the correct inbound policy section.


Conclusion

The Send-Service-Bus-Message policy is one of the most valuable features to arrive in Azure API Management. It brings direct messaging capabilities into your API gateway, enabling faster and more secure integrations without custom code or extra services.