---
title: "Set up External Data Feed with Azure Event Hubs and Power BI"
slug: "set-up-external-data-feed-with-azure-event-hubs-and-power-bi"
abstract: "How to configure Sitecore Content Hub External Data Feed with Azure Event Hubs and visualize events in Power BI."
---
# Set up External Data Feed with Azure Event Hubs and Power BI

> [!note]
> To configure Content Hub, you must either be a superuser or have the necessary permissions granted to you through [user group policies](https://doc.sitecore.com/ch/en/users/content-hub/user-group-policies.html).

This walkthrough shows how to configure Sitecore Content Hub's [External Data Feed](https://doc.sitecore.com/ch/en/developers/cloud-dev/external-data-feed.html "External Data Feed") with Azure Event Hubs and visualize entity lifecycle events in Power BI.

> [!note]
> **Before you begin**
> -   Make sure that you have an Azure subscription and access to configure resources in Azure.

This walkthrough describes how to:

:::walkthrough
1. [Create resources in Azure](https://doc.sitecore.com/ch/en/developers/cloud-dev/set-up-external-data-feed-with-azure-event-hubs-and-power-bi.html#create-resources-in-azure)
2. [Configure Content Hub ExternalDataFeed](https://doc.sitecore.com/ch/en/developers/cloud-dev/set-up-external-data-feed-with-azure-event-hubs-and-power-bi.html#configure-content-hub-externaldatafeed)
3. [Prepare data for Power BI with Stream Analytics](https://doc.sitecore.com/ch/en/developers/cloud-dev/set-up-external-data-feed-with-azure-event-hubs-and-power-bi.html#prepare-data-for-power-bi-with-stream-analytics)
4. [Build a Power BI report](https://doc.sitecore.com/ch/en/developers/cloud-dev/set-up-external-data-feed-with-azure-event-hubs-and-power-bi.html#build-a-power-bi-report)
:::

## Create resources in Azure

1. In the [Azure portal](https://portal.azure.com), create a resource group if you do not already have one.
2. In the resource group, create an **Event Hubs** resource. This creates an **Event Hubs Namespace**.
3. When the deployment is complete, go to the resource and create an **Event Hub** inside that Namespace.
4. Go to the Events Hub Instance > **Settings** > **Shared access policies** and create a policy.
5. Copy the **Primary connection string**. You will use it for the `saslPassword` setting when you configure Content Hub.

## Configure Content Hub ExternalDataFeed

After creating the required Azure resources, you need to configure Content Hub to send events to the Event Hub you created.

To configure Content Hub:

1. In Content Hub, configure the **ExternalDataFeed** > **Export** setting with the following:

    ```json
    {
      "entityDefinitions": [
        "M.Asset",
        "M.Brand",
        "M.Geography",
        "M.Color",
        "M.Tag"
      ]
    }
    ```

    The **Export** setting defines which entity definitions send events.

2. Click **Save**.
3. Configure the **ExternalDataFeed** > **Transport** setting with the following:

    ```json
    {
      "kafka": {
        "enabled": true,
        "bootstrapServers": [
          "{event-hubs-namespace-hostname}:9093"
        ],
        "topic": "{event-hub-instance-name}",
        "clientId": "contenthub-external-data",
        "securityProtocol": "SaslSsl",
        "saslUsername": "$ConnectionString",
        "saslPassword": "{event-hub-instance-primary-connection-string}"
      }
    }
    ```

4. Click **Save**.
5. Go to your Events Hub Instance > **Data Explorer** and check for incoming events.

    ![external-data-feed-events.jpeg](https://doc.sitecore.com/api/markdown-image/ch/en/developers/cloud-dev/images/external-data-feed-events.jpeg)

## Prepare data for Power BI with Stream Analytics

After configuring Content Hub, you need to create and configure Stream Analytics.

To prepare data for Power BI with Stream Analytics:

1. In the resource group you created earlier, create a **Stream Analytics job** resource.
2. When the deployment is complete, go to the resource and then **Job topology** > **Query**.
3. On the **Query** page:
    - Add an **Input** of type **Event Hub**. Use the **Event Hub namespace** and **Event Hub name** that you created earlier.
    - Add an **Output** of type **Power BI**. For the **Authentication mode**, use **Managed Identity: System assigned**.
4. Add the following query, then test and save it, and start the Stream Analytics job.

    ```

    SELECT
        tenant,
        eventType,
        payload.id AS id,
        payload.identifier AS identifier,
        payload.modifiedOn AS modifiedOn
    INTO
        [YourOutputName]
    FROM
        [YourInputName]
    ```

    ![azure-stream-analytics-job-query.jpeg](https://doc.sitecore.com/api/markdown-image/ch/en/developers/cloud-dev/images/azure-stream-analytics-job-query.jpeg)

    After a few minutes, a streaming dataset is created in your Power BI environment.

## Build a Power BI report

After the streaming dataset appears in Power BI, you can create reports and add visuals for event monitoring.

![power-bi-ch-report.jpeg](https://doc.sitecore.com/api/markdown-image/ch/en/developers/cloud-dev/images/power-bi-ch-report.jpeg)

For example, here is a pie chart to visualize the `Entity saved` and `Entity deleted` events:

![power-bi-pie-chart.jpeg](https://doc.sitecore.com/api/markdown-image/ch/en/developers/cloud-dev/images/power-bi-pie-chart.jpeg)