Add PostgreSQL Database CDC source to an eventstream

This article shows you how to add a PostgreSQL Database Change Data Capture (CDC) source to an eventstream.

The PostgreSQL Database Change Data Capture (CDC) source connector for Microsoft Fabric event streams 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. Once the changes are captured in the eventstream, you can process this CDC data in real-time and send it to different destinations within Fabric for further processing or analysis.

Note

This source is not supported in the following regions of your workspace capacity: West US3, Switzerland West.

Prerequisites

Enable CDC in your Azure Database for PostgreSQL

To enable CDC in your Azure Database for PostgreSQL Flexible Server, follow these steps:

  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. If you want to use other user account to connect your PostgreSQL DB to fetch CDC, please ensure the user is the table owner.

    ALTER ROLE <admin_user_or_table_owner_user> WITH REPLICATION;
    

Launch the Select a data source wizard

If you haven't added any source to your eventstream yet, select Use external source tile.

Screenshot that shows the selection of Use external source tile.

If you're adding the source to an already published eventstream, switch to Edit mode, select Add source on the ribbon, and then select External sources.

Screenshot that shows the selection of Add source to External sources menu.

On the Select a data source page, search for and select Connect on the Azure DB for PostgreSQL (CDC) tile.

Screenshot that shows the selection of Azure DB for PostgreSQL (CDC) as the source type in the Get events wizard.

Configure and connect to Azure Database for PostgreSQL CDC

  1. On the Connect page, select New connection.

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

  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 event streams 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. 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 Add.

    Screenshot that shows the Review and create page filled for the Azure PostgreSQL database connector.

Note

The maximum number of sources and destinations for one eventstream is 11.

View updated eventstream

  1. You can see the PostgreSQL Database CDC source added to your eventstream in Edit mode.

    A screenshot of streaming PostgreSQL DB CDC source in Edit view.

  2. To implement this newly added PostgreSQL DB CDC source, select Publish. After you complete these steps, your PostgreSQL DB CDC source is available for visualization in the Live view.

    A screenshot of streaming PostgreSQL DB CDC source in Live view.

Other connectors: