Get started with the Azure Event Hubs connector
Connect to Azure Event Hubs to send and receive events. You can perform operations such as send an event to an Event Hub and receive events from an Event Hub.
Connect to Event Bus
Before your logic app can access any service, you first need to create a connection to the service. A connection provides connectivity between a logic app and another service.
You must have an Event Hubs account.
Before you can use your Azure Event Hubs account in a logic app, you must authorize the logic app to connect to your Event Hubs account. Fortunately, you can do this easily from within your logic app on the Azure portal.
Here are the steps to authorize your logic app to connect to your Event Hubs account:
To create a connection to Event Hubs, in the logic app designer, select Show Microsoft managed APIs in the drop-down list. Then enter event hubs in the search box. Select the trigger or action you want to use.
If you haven't created any connections to Event Hubs before, you'll be prompted to provide your Event Hubs credentials. These credentials are used to authorize your logic app to connect to and access your Event Hubs’ data. The Event Hubs connector needs the connection string for the Event Hubs namespace. It also requires Manage permissions. A good way to know if your connection string is for the namespace or a specific entity is if it contains the EntityPath parameter. If it does, it is not the right connection string for a logic app.
After you have received the connection string for the namespace, you can use it for the API connection in Logic Apps.
Notice the connection has been created, and you are now free to proceed with the other steps in your logic app.
Use an Event Hubs trigger
A trigger is an event that can be used to start the workflow defined in a logic app. Learn more about triggers.
Here's how to use the Event Hubs - When events are available in Event Hub trigger to initiate a logic app workflow when new events are sent to an Event Hub.
You will be prompted to sign in with your Event Hubs connection string if you have not already created a connection to Event Hubs.
- In the search box on the logic apps designer, enter event hubs. Then select the Event Hubs - When events are available in an Event Hub
- The When an event in available in an Event Hub dialog box is displayed.
- Enter the name of the Event Hub you would like the trigger to monitor. Optionally, you can also select a consumer group.
At this point, your logic app has been configured with a trigger. When new events are available in the Event Hub you selected, the trigger will begin a run of the other triggers and actions in the workflow.
Use an Event Hubs action
An action is an operation carried out by the workflow defined in a logic app. Learn more about actions.
Now that you have added a trigger, it's time to do something interesting with the data that's generated by the trigger. Follow these steps to add the Event Hubs - Send event action. This action sends an event to an Event Hub.
Follow these steps to create the send event action:
- Select + New step to add the action.
- Select Add an action. This opens a search box, where you can search for any action you would like to take. For this example, Event Hubs’ actions are of interest.
- Enter event hubs.
- Select Event Hubs - Send event as the action to take
- Enter the content for the event. This is required.
- Enter the event hub name to which the event will be sent. This is also required.
- Provide other details about the event. This is optional.
- Save the changes to your workflow.