Send and receive messages with the Azure Service Bus connector
To send and receive messages with your logic app, connect to Azure Service Bus. You can perform actions such as send to a queue, send to a topic, receive from a queue, and receive from a subscription. Learn more about Azure Service Bus and how pricing works for Logic Apps triggers.
Before you can use the Service Bus connector, you must have these items, which must exist in the same Azure subscription so that they're visible to each other:
Connect to Azure Service Bus
Before your logic app can access any service, you have to create a connection between your logic app and the service, if you haven't already. This connection authorizes your logic app to access data. For your logic app to access your Service Bus account, check your permissions.
Sign in to the Azure portal.
Go to your Service Bus namespace, not a specific "messaging entity". On the namespace page, under Settings, choose Shared access policies. Under Claims, check that you have Manage permissions for that namespace.
If you want to later manually enter your connection information, get the connection string for your Service Bus namespace. Choose RootManageSharedAccessKey. Next to your primary key connection string, choose the copy button. Save the connection string for later use.
To confirm whether your connection string is associated with your Service Bus namespace or with a specific entity, check the connection string for the
EntityPathparameter. If you find this parameter, the connection string is for a specific entity, and is not the correct string to use with your logic app.
Trigger workflow when your Service Bus gets new messages
A trigger is an event that starts a workflow in your logic app. To start a workflow when new messages are sent to your Service Bus, follow these steps for adding the trigger that detects these messages.
In the Azure portal, go to your existing logic app or create a blank logic app.
In Logic Apps Designer, enter "service bus" in the search box as your filter. Select the Service Bus connector.
Select the trigger that you want to use. For example, to run a logic app when a new item gets sent to a Service Bus queue, select this trigger: Service Bus - When a message is received in a queue (auto-complete)
Some triggers return one or messages, such as the Service Bus - When one or more messages arrive in a queue (auto-complete) trigger. When these triggers fire, they return between one and the number of messages specified by the trigger's Maximum message count property.
If you don't already have a connection to your Service Bus namespace, you're prompted to create this connection now. Give your connection a name, and select the Service Bus namespace that you want to use.
Or, to manually enter the connection string, choose Manually enter connection information. Learn how to find your connection string.
Now select the Service Bus policy to use, and choose Create.
Select the Service Bus queue to use, and set up the interval and frequency for when to check the queue.
All Service Bus triggers are long-polling triggers, which means that when a trigger fires, the trigger processes all the messages and then waits for 30 seconds for more messages to appear in the queue or topic subscription. If no messages are received in 30 seconds, the trigger run is skipped. Otherwise, the trigger continues reading messages until the queue or topic subscription is empty. The next trigger poll is based on the recurrence interval specified in the trigger's properties.
Save your logic app. On the designer toolbar, choose Save.
Now, when your logic app checks the selected queue and finds a new message, the trigger runs the actions in your logic app for the found message.
Send messages from your logic app to your Service Bus
An action is a task performed by your logic app workflow. After you add a trigger to your logic app, you can add an action to perform operations with data generated by that trigger. To send a message to your Service Bus messaging entity from your logic app, follow these steps.
In Logic Apps Designer, under your trigger, choose + New step > Add an action.
In the search box, enter "service bus" as your filter. Select this connector: Service Bus
Select this action: Service Bus - Send message
Select the messaging entity, which is the queue or topic name, for where to send the message. Then, enter the message content and any other details.
Save your logic app.
You've now set up an action that sends messages from your logic app.
To learn more about triggers and actions defined by the Swagger file and any limits, review the connector details.
- For questions, visit the Azure Logic Apps forum.
- To submit or vote on feature ideas, visit the Logic Apps user feedback site.
- Learn more about other connectors for Azure Logic apps