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
Access to a workspace in the Fabric capacity license mode (or) the Trial license mode with Contributor or higher permissions.
Registered user access in the PostgreSQL database.
CDC enabled in the PostgreSQL database.
If you have Azure Database for PostgreSQL, follow the steps in the next section to enable CDC. For detailed information, see Logical replication and logical decoding - Azure Database for PostgreSQL - Flexible Server.
For other PostgreSQL databases, see Debezium connector for PostgreSQL :: Debezium Documentation.
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
Go to the Replication page on the Azure portal.
Change the replication rule to Logical.
Azure Database for PostgreSQL flexible server
On your Azure Database for PostgreSQL flexible server page in the Azure portal, select Server parameters in the navigation menu.
On the Server parameters page:
Set wal_level to logical.
Update the max_worker_processes to at least 16.
Save the changes and restart the server.
Confirm that your Azure Database for PostgreSQL flexible server instance allows public network traffic.
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
Sign in to Microsoft Fabric.
Select Real-Time on the left navigation bar.
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.
On the Data sources page, select Microsoft sources category at the top, and then select Connect on the Azure DB for PostgreSQL (CDC) tile.
Use instructions from the Add PostgreSQL Database CDC as a source section.
Microsoft sources page
In Real-Time hub, select Microsoft sources.
In the Source drop-down list, select PostgreSQL (CDC).
For Subscription, select an Azure subscription that has the resource group with your PostgreSQL Database account.
For Resource group, select a resource group that has the database.
For Region, select a location where your database is located.
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.
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
On the Connect page, select New connection.
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.
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.
Scroll down, and in the Connection credentials section, follow these steps.
For Connection name, enter a name for the connection.
For Authentication kind, select Basic.
Note
Currently, Fabric eventstreams supports only Basic authentication.
Enter Username and Password for the database.
Select Connect.
Now, on the Connect page, do these steps:
For table, Enter a table name.
For Port, enter the port number or leave the default value: 5432.
For eventstream name, enter a name for the eventstream. The wizard creates an eventstream with the selected PostgreSQL Database CDC as a source.
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.
Select Next at the bottom of the page.
On the Review + connect page, review the summary, and then select Connect.
View data stream details
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.
In Real-Time hub, select My data streams. To see the new data stream, refresh the page.
Related content
To learn about consuming data streams, see the following articles: