Add PostgreSQL Database CDC as source in Real-Time hub

This article describes how to add PostgreSQL Database Change Data Capture (CDC) as an event source in Fabric Real-Time hub.

The PostgreSQL Database Change Data Capture (CDC) source connector for Microsoft Fabric eventstreams allows you to capture a snapshot of the current data in a PostgreSQL database. The connector then monitors and records any future row-level changes to this data.

Prerequisites

Note

Multiple tables CDC isn't supported.

Enable CDC in your Azure Database for PostgreSQL

To enable CDC in your Azure Database for PostgreSQL, follow these steps based on your deployment type.

Azure Database for PostgreSQL single server

  1. Go to the Replication page on the Azure portal.

  2. Change the replication rule to Logical.

    A screenshot of enabling CDC for a single server deployment.

Azure Database for PostgreSQL flexible server

  1. On your Azure Database for PostgreSQL flexible server page in the Azure portal, select Server parameters in the navigation menu.

  2. On the Server parameters page:

    • Set wal_level to logical.

    • Update the max_worker_processes to at least 16.

      A screenshot of enabling CDC for a flexible server deployment.

  3. Save the changes and restart the server.

  4. Confirm that your Azure Database for PostgreSQL flexible server instance allows public network traffic.

  5. Grant the admin user replication permissions by running the following SQL statement.

    ALTER ROLE <admin user> WITH REPLICATION;
    

Get events from an Azure Database for PostgreSQL CDC

You can get events from an Azure Database for PostgreSQL CDC into Real-Time hub in one of the ways:

Data sources page

  1. Sign in to Microsoft Fabric.

  2. Select Real-Time on the left navigation bar.

  3. On the Real-Time hub page, select + Data sources under Connect to on the left navigation menu. You can also get to the Data sources page from All data streams or My data streams pages by selecting the + Connect data source button in the top-right corner.

    Screenshot that shows how to launch Connect to data source experience.

  1. On the Data sources page, select Microsoft sources category at the top, and then select Connect on the Azure DB for PostgreSQL (CDC) tile.

    Screenshot that shows the selection of Azure Database (DB) for PostgreSQL (CDC) as the source type in the Data sources page.

    Use instructions from the Add PostgreSQL Database CDC as a source section.

Microsoft sources page

  1. In Real-Time hub, select Microsoft sources.

  2. In the Source drop-down list, select PostgreSQL (CDC).

  3. For Subscription, select an Azure subscription that has the resource group with your PostgreSQL Database account.

  4. For Resource group, select a resource group that has the database.

  5. For Region, select a location where your database is located.

  6. Now, move the mouse over the name of the PostgreSQL Database CDC source that you want to connect to Real-Time hub in the list of databases, and select the Connect button, or select ... (ellipsis), and then select the Connect button.

    Screenshot that shows the Microsoft sources page with filters to show Azure PostgreSQL CDC and the connect button.

    To configure connection information, use steps from the Add Azure Database for PostgreSQL CDC as a source section.

Add Azure Database for PostgreSQL CDC as a source

  1. On the Connect page, select New connection.

    Screenshot that shows the Connect page for an Azure PostgreSQL database with New connection link highlighted.

    If you have an existing connection to your Azure Database for PostgreSQL CDC source, you can select it from the Connection drop-down list, and move on to configuring port and tables.

    Screenshot that shows the Connect page with an existing connection selected.

  2. In the Connection settings section, enter the following information.

    • Server: The server address of your PostgreSQL database, for example my-pgsql-server.postgres.database.azure.com.

    • Database: The database name, for example my_database.

      Screenshot that shows the Connection settings section for the Azure PostgreSQL database connector.

  3. Scroll down, and in the Connection credentials section, follow these steps.

    1. For Connection name, enter a name for the connection.

    2. For Authentication kind, select Basic.

      Note

      Currently, Fabric eventstreams supports only Basic authentication.

    3. Enter Username and Password for the database.

    4. Select Connect.

      Screenshot that shows the Connection credentials section for the Azure PostgreSQL database connector.

  4. Now, on the Connect page, do these steps:

    1. For table, Enter a table name.

    2. For Port, enter the port number or leave the default value: 5432.

    3. For eventstream name, enter a name for the eventstream. The wizard creates an eventstream with the selected PostgreSQL Database CDC as a source.

    4. The Stream name is automatically generated for you by appending -stream to the name of the eventstream. You see this stream on the All data streams page when the wizard finishes.

    5. Select Next at the bottom of the page.

      Screenshot that shows the Connect page filled for the Azure PostgreSQL database connector.

  5. On the Review + connect page, review the summary, and then select Connect.

    Screenshot that shows the Review + connect page filled for the Azure PostgreSQL database connector.

View data stream details

  1. On the Review + connect page, if you select Open eventstream, the wizard opens the eventstream that it created for you with the selected PostgreSQL Database CDC as a source. To close the wizard, select Finish at the bottom of the page.

    Screenshot that shows the Review + connect success page.

  2. In Real-Time hub, select My data streams. To see the new data stream, refresh the page.

    Screenshot that shows the Real-Time hub My data streams page with the stream based on PostgreSQL Database CDC source.

To learn about consuming data streams, see the following articles: