Add PostgreSQL Database CDC as source in Real-Time hub (preview)
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 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.
Note
Real-Time hub is currently in preview.
Prerequisites
Get access to the Fabric premium workspace with Contributor or above 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;
Launch Add source experience
Sign in to Microsoft Fabric.
Select Real-Time hub on the left navigation bar.
On the Real-Time hub page, select + Add source in the top-right corner of the page.
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 Azure MySQL 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 MySQL DB CDC as a source section. Skip the first step of selecting Azure MySQL DB CDC as a source type in the Add source wizard.
Add Azure Database for PostgreSQL CDC as a source
On the Select a data source screen, select Azure DB for PostgreSQL (CDC).
On the Connect page, select Go to resource to navigate to the Azure PostgreSQL database. Take a note of the server name on the Overview page. It's in the following format:
myazurepostgresqlserver.postgres.database.azure.com
.On the Connect page, select New connection.
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 event streams 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 and create screen, review the summary, and then select Create source.
View data stream details
On the Review and create 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 Close at the bottom of the page.
In Real-Time hub, select All data streams. To see the new data stream, refresh the All data streams page.
Related content
To learn about consuming data streams, see the following articles: