Connecting to an Azure Database for PostgreSQL
How to connect Sequin to an Azure Database for PostgreSQL
This guide provides step-by-step instructions to connect your Azure Database for PostgreSQL to Sequin.
Enable logical replication on Azure Database for PostgreSQL
By default, logical replication is not enabled on Azure Database for PostgreSQL. To enable it, follow these steps:
Configure server parameters
In the Azure Portal, navigate to your Azure Database for PostgreSQL server and follow these steps:
- Go to the Server parameters page
- Set the following parameters:
wal_level
: Set tological
shared_preload_libraries
: Addpglogical
to the list (if not already present)azure.extensions
: Addpglogical
to the list (if not already present)max_worker_processes
: Set to at least16
- Click Save to apply the changes
Restart the server
After changing the server parameters, you need to restart your server for the changes to take effect. In the Azure Portal:
- Go to the Overview page of your PostgreSQL server
- Click the Restart button at the top of the page
- Confirm the restart when prompted
Grant replication permissions
Connect to your database using a SQL client and run the following SQL command to grant replication permissions to your user:
ALTER ROLE <username> WITH REPLICATION;
Replace <username>
with your admin username.
It’s recommended to create a separate user for replication instead of using the admin account. Ensure this user has the necessary privileges on the schema you’re replicating.
Configure network access
Ensure that your Azure Database for PostgreSQL server allows network traffic from your connecting resource. You may need to add firewall rules or configure virtual network settings in the Azure Portal.
Read more about how to setup logical replication in Azure Database for PostgreSQL here.
Connect Sequin to your Azure Database for PostgreSQL
After enabling logical replication on Azure Database for PostgreSQL, you’ll now connect to your database in Sequin.
Enter connection details in Sequin
In the Sequin Console, click on the Connect Database button and enter the credentials for your Azure Database for PostgreSQL:
You can find these connection details in your Azure Portal under the PostgreSQL server’s Connection strings section.
- Host: Your Azure PostgreSQL server hostname
- Port: 5432 (default Postgres port)
- Database: Your database name
- Username: Your database username (with replication permissions)
- Password: The password for your database user
Make sure to enable the SSL option for secure connection.
Create a replication slot
Connect to your database using the SQL client of your choice and execute the following SQL query to create a replication slot:
SELECT pg_create_logical_replication_slot('sequin_slot', 'pgoutput');
This creates a replication slot named sequin_slot
.
Create a publication
Next, create a publication to indicate which tables will publish changes to the replication slot. Run the following SQL command:
CREATE PUBLICATION sequin_pub FOR TABLE table1, table2, table3;
If you want to publish changes from all tables, you can use:
CREATE PUBLICATION sequin_pub FOR ALL TABLES;
Enter the replication slot details in Sequin
Back in the Sequin Console, enter the name of the replication slot (e.g. sequin_slot
) and publication (e.g. sequin_pub
) you just created. Then, name your database and click Create Database.
Create a consumer
With your Azure Database for PostgreSQL connected to Sequin via a replication slot and publication, Sequin is now detecting changes to your tables. Now create a consumer to process your data changes and send them to your application.
Click the Add a consumer button and select your Azure Database for PostgreSQL as the source. Follow the instructions in our quickstart guide to complete the process.
Next steps
With your Azure Database for PostgreSQL connected to Sequin, you can now:
- Set up filters to capture specific changes.
- Use Sequin’s observability features to monitor and debug your data flows.
- Explore Sequin’s replay and backfill features for historical data processing.
For more information on these features, learn how Sequin works.