This guide provides step-by-step instructions to connect your Azure Database for PostgreSQL to Sequin.

Provision a Postgres user for Sequin

When in development, it’s probably fine to supply Sequin with an existing user.

However, when in production, you should create a dedicated user for Sequin. The user needs the following permissions:

  1. connect permission on the database.
  2. select permission on all the tables you want to connect to Sequin.
  3. replication permission to read from replication slots.

Here’s how to create a dedicated user with the minimum required permissions:

-- Create user with a secure password
create user sequin_user with password 'REPLACE_WITH_SECURE_PASSWORD';

-- Grant connect permission
grant connect on database your_database to sequin_user;

-- Grant select permission on tables you want to replicate
grant select on table table1, table2, table3 to sequin_user;
-- OR grant select on all tables in a schema
grant select on all tables in schema public to sequin_user;

-- Grant replication permission
alter user sequin_user with replication;

To generate a secure password, if you have OpenSSL installed, you can use the following command:

openssl rand -base64 32

Enable logical replication on Azure Database for PostgreSQL

By default, logical replication is not enabled on Azure Database for PostgreSQL. You can double check if logical replication is enabled by connecting to your database and running the following command:

SHOW rds.logical_replication;

If the output is off, then logical replication is not enabled.

To enable it, follow these steps:

Enabling replication requires a restart of your database server.
1

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 to logical
    • shared_preload_libraries: Add pglogical to the list (if not already present)
    • azure.extensions: Add pglogical to the list (if not already present)
    • max_worker_processes: Set to at least 16
  • Click “Save” to apply the changes
2

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
3

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.

1

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: The sequin database user you created earlier
  • Password: The password for your sequin database user

Make sure to enable the “SSL” option for secure connection.

2

Create a publication

Connect to your database using the SQL client of your choice and execute the following SQL query to create a publication:

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;
3

Create a replication slot

Next, create a replication slot to capture changes from the publication:

SELECT pg_create_logical_replication_slot('sequin_slot', 'pgoutput');
4

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 sink

With your Azure Database connected to Sequin, you are ready to create a sink. Follow one of our guides below to get started:

Was this page helpful?