Edit

Share via


Stream events to Eventstream using Logic Apps and Power Automate

In this tutorial, you learn how to stream real-time events from Logic Apps or Power Automate to Real-Time Intelligence using a custom endpoint source in Microsoft Fabric Eventstream. While the flows for Logic Apps and Power Automate are configured differently, they serve the same purpose: to periodically send the simulated flight data containing columns such as ScanUtcTime and FlightInfo. The difference in flow is because Logic Apps supports executing JavaScript, but Power Automate doesn't.

The flow in Logic App (with stateful workflow) and Power Automate are:

  • Logic Apps Flow:

    Screenshot showing logic app flow.

  • Power Automate Flow:

    Screenshot showing Power Automate flow.

Although the flows in Logic Apps and Power Automate are different, they achieve the same result—sending flight data to Real-Time Intelligence. Choose the approach that best suits your requirements.

Screenshot showing flight data in eventstream.

In this tutorial, you learn how to:

  • Create an eventstream and add a custom endpoint source.
  • Getting the Event Hubs endpoint details.
  • Connecting Logic Apps to the eventstream via the custom endpoint.
  • Connecting Power Automate to the eventstream via the custom endpoint.
  • Preview data in eventstream.

Prerequisites

Before you start, you must complete the following prerequisites:

  • Access to a workspace with Contributor or higher permissions where your eventstream is located.
  • For Logic Apps, an Azure account with a valid subscription to create logic apps. If you don't have one, sign up for a free Azure account.
  • For Power Automate, an active Power Automate account.

Create an eventstream

  1. Navigate to the Fabric portal.

  2. Select My workspace on the left navigation bar.

  3. On the My workspace page, select + New item on the command bar.

  4. On the New item page, search for Eventstream, and then select Eventstream.

    Screenshot that shows the New item page with Eventstream selected.

  5. In the New Eventstream window, enter a name for the eventstream, and then select Create.

    Screenshot that shows the New Eventstream window.

  6. Creation of the new eventstream in your workspace can take a few seconds. After the eventstream is created, you're directed to the main editor where you can start with adding sources to the eventstream.

    Screenshot showing the editor.

Add a Custom endpoint source

  1. To add a custom endpoint source, on the get-started page, select Use custom endpoint.

    Screenshot of the option to use a custom endpoint.

  2. In the Custom endpoint dialog, enter a name for the custom source under Source name, and then select Add.

    Screenshot of the dialog for adding a custom endpoint.

  3. After you create the custom endpoint source, it's added to your eventstream on the canvas in edit mode. To implement the newly added data from the custom app source, select Publish.

    Screenshot that shows the eventstream in edit mode, with the Publish button highlighted.

Stream events from Logic Apps to your eventstream using the custom endpoint

In this section, you'll learn how to design a workflow that periodically generates simulated flight data on a recurring schedule. The workflow will use JavaScript code in the 'Execute JavaScript' action to construct a flight information message with randomized values for each field. Once the message is constructed, it will be sent to the eventstream's endpoint using the Event Hub protocol.

  1. Create a Logic App using the Standard plan instead of the Consumption plan to simplify configuration, as the 'Execute JavaScript' action in the Consumption plan requires an additional integration account.

    Screenshot that shows create logic app with standard plan.

  2. Create a workflow. When creating the workflow, select the Stateful state type as the 'Recurrence' trigger (needed for this tutorial) is not available in the stateless trigger list.

    Screenshot that shows create workflow with stateful state type.

  3. Open the newly created workflow, select Add a trigger, and then select Recurrence.

    Screenshot that shows how to add a recurrence in workflow.

  4. Configure Recurrence for periodical running. This will peroridically trigger this whole flow based on the interval you set.

    Screenshot that shows how to set recurrence for long running.

  5. Select the + Add an action and then select the Excute JavaScript.

    Screenshot that shows how to add JavaScript.

  6. Copy this script content into code field.

    Screenshot that shows JavaScript code.

  7. Select the + Add an action to add the Event Hubs action step, and then select Send event.

    Screenshot that shows how to add an event hub.

  8. Create new connection, enter the Connection name.

  9. Enter the Connection string which can copy from Eventstream Custom endpoint, and select Create new to get the connection created.

    Screenshot showing how to get connection string.

  10. After the new connection created and returned to event hub Parameters configuration, select Enter custom value from the dropdown menu of the Event Hub Name and enter the event hub name which can copy from Eventstream Custom endpoint.

    Screenshot showing how to get Event Hubs name.

  11. Select Content for the Advanced parameters and configure the Content as the Output .

    Screenshot showing configure event hub content.

    Screenshot showing configure event hub as output.

  12. Select Save to save the workflow.

    Screenshot showing how to save workflow.

  13. On the designer toolbar, from the Run menu, select Run.

    Screenshot showing how to run workflow.

  14. After you complete these steps, you can preview the data in your eventstream that is from your Logic App workflow.

    Screenshot showing data preview in eventstream.

Stream events from Power Automate to your eventstream using the custom endpoint

In this section, you'll learn how to create a flow in Power Automate to generate simulated flight data and send it to your eventstream. Since Power Automate doesn't support the 'Execute JavaScript Code' action, a few variables need to be defined to produce the simulated data. To simplify this process, a preconfigured flow with the necessary variables is provided for downloading and importing. Follow the steps below to create your flow using the preconfigured package and complete the remaining configuration to send the simulated data to your eventstream.

  1. Download this zip file from this git repo which contains preconfigured flows for scheduling the sending of mock flight data.

  2. Login in Power Automate with your Power BI account.

  3. Navigate to My Flows in the left navigating pane.

    Screenshot showing create Power Automate flow.

  4. Select the Import Package (Legacy) after clicking the Import button.

    Screenshot showing importing package.

  5. Select the zip file you downloaded from step 1, and upload it.

  6. Select update to change the Import setup as Create as new, and then select Save.

    Screenshot showing updating as create as new.

  7. And then select Import to import this package to your own flow.

    Screenshot showing the last step to import package.

  8. Navigate back to My Flows, and you can see the newly added Power Automate flow.

    Screenshot showing the newly added flow.

  9. Open your Power Automate flow, select Edit and add the Event Hubs action step, and then select Send event. Refer to the steps in stream events from Logic Apps to configure the event hub and set Recurrence for long-running.

    Screenshot showing hoe to add event hub in automate flow.

  10. Navigate back to My Flows, and select the flow to Turn on it

    Screenshot showing how to turn on automate flow.

  11. After you complete these steps, you can preview the data in your eventstream that is from your Power Automate workflow.

    Screenshot showing data preview in eventstream.

In this tutorial, you learned how to stream real-time events from Power Automate or Logic Apps to your eventstream using the custom endpoint.

If you want to discover more advanced functionalities for working with Fabric event streams, you might find the following resources helpful: