Preparing Your Azure PostgreSQL Database for Logical Replication to Linode Managed Database

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

Logical replication continuously synchronizes database tables, allowing you to prepare the destination database in advance. This approach minimizes downtime when you switch application traffic and retire the source database.

This guide explains how to prepare an Azure Database for PostgreSQL for logical replication to a Linode Managed Database. Follow this guide before returning to the Logical Replication to a Linode Managed PostgreSQL Database guide to create the subscription on Akamai Cloud.

Follow the steps in this guide to:

  • Configure your Azure Database instance to support logical replication.
  • Ensure secure network access from Linode.
  • Create a dedicated replication user.
  • Set up a publication for the tables you wish to replicate.

After completing these steps, return to Logical Replication to a Linode Managed PostgreSQL Database to configure the subscriber and finalize the setup.

Before You Begin

  1. Follow the Logical Replication to a Linode Managed PostgreSQL Database guide up to the Prepare the Source Database for Logical Replication section to obtain the public IP address or CIDR range of your Linode Managed Database.

  2. Ensure your Azure account has permissions to modify PostgreSQL server parameters, networking settings, and firewall rules.

  3. Install and authenticate the Azure CLI on your local machine:

    az login
    az account set --subscription YOUR_AZURE_SUBSCRIPTION_ID
Requirement: Flexible Server
Ensure you have an Azure Database for PostgreSQL – Flexible Server instance. Logical replication requires Flexible Server, as Single Server was retired in March 2025.

Placeholders and Examples

The following placeholders and example values are used in commands throughout this guide:

ParameterPlaceholderExample Value
Azure Server NameAZURE_SERVER_NAMEsource-database
Azure Resource GroupAZURE_RESOURCE_GROUPpg-repl-rg
Destination IP AddressDEST_IP172.232.188.122
Source HostnameSOURCE_HOSTsource-database.postgres.database.azure.com
Source PortSOURCE_PORT5432
Source UsernameSOURCE_USERazureadmin
Source DatabaseSOURCE_DBpostgres
Source PasswordSOURCE_PASSWORDthisismysourcepassword
Replication UsernameREPL_USERlinode_replicator
Replication PasswordREPL_PASSWORDthisismyreplicatorpassword
Publication NamePUBLICATION_NAMEmy_publication

Replace these placeholders with your own connection details when running commands in your environment.

Additionally, the examples used in this guide assume the source database contains three tables (customers, products, and orders) that you want to replicate to a Linode Managed Database.

Configure Server Parameters

To support logical replication, you’ll need to adjust a few parameters on your Azure Database for PostgreSQL instance.

  1. In the Azure Portal, locate your database resource, then navigate to Settings > Server parameters:

    Azure Database for PostgreSQL Flexible Server - Navigation menu with Server parameters selected.

  2. In the list of server parameters, use the search filter to find the values for wal_level, max_replication_slots, and max_wal_senders:

    In order for logical replication to succeed, these values should be as follows:

    • max_replication_slots: Greater than or equal to 1
    • max_wal_senders: Greater than or equal to max_replication_slots, depending on expected replication concurrency
    • wal_level: LOGICAL

    If these values are already set correctly, skip the remainder of this section and continue with Configure Network Access. Otherwise, you need to modify the parameter group using the instructions below.

  3. Adjust the values as needed, then click Save:

  4. When Azure notifies you that you need to restart the server for changes to take effect, click Save and Restart.

  1. Run the following az CLI command to list the relevant server parameters for the instance. Replace AZURE_SERVER_NAME with your Azure PostgreSQL server name (e.g., source-database) and AZURE_RESOURCE_GROUP with your resource group (e.g., pg-repl-rg):

    az postgres flexible-server parameter list \
      --server-name AZURE_SERVER_NAME \
      --resource-group AZURE_RESOURCE_GROUP \
      --output json \
      --query "[?name=='wal_level' || name=='max_replication_slots' || name=='max_wal_senders'].{name:name, description:description, dataType:dataType, value:value}"
    [
      {
        "dataType": "Integer",
        "description": "Specifies the maximum number of replication slots that the server can support.",
        "name": "max_replication_slots",
        "value": "10"
      },
      {
        "dataType": "Integer",
        "description": "Sets the maximum number of simultaneously running WAL sender processes.",
        "name": "max_wal_senders",
        "value": "10"
      },
      {
        "dataType": "Enumeration",
        "description": "It determines how much information is written to the WAL.",
        "name": "wal_level",
        "value": "REPLICA"
      }
    ]

    In order for logical replication to succeed, these values should be as follows:

    • max_replication_slots: Greater than or equal to 1
    • max_wal_senders: Greater than or equal to max_replication_slots, depending on expected replication concurrency
    • wal_level: LOGICAL

    If these values are already set correctly, skip the remainder of this section and continue with Configure Network Access. Otherwise, you need to modify the parameter group using the instructions below.

    To adjust the values with the Azure CLI, you need to run the parameter set command for each parameter.

  2. Use the following command to adjust the value of max_replication_slots to 10:

    az postgres flexible-server parameter set \
      --server-name AZURE_SERVER_NAME \
      --resource-group AZURE_RESOURCE_GROUP \
      --name max_replication_slots \
      --value 10
  3. Use the following command to adjust the value of max_wal_senders to 10:

    az postgres flexible-server parameter set \
      --server-name AZURE_SERVER_NAME \
      --resource-group AZURE_RESOURCE_GROUP \
      --name max_wal_senders \
      --value 10
  4. Use the following command to adjust the value of wal_level to logical:

    Modify server parameters to support logical replication
    az postgres flexible-server parameter set \
      --server-name AZURE_SERVER_NAME \
      --resource-group AZURE_RESOURCE_GROUP \
      --name wal_level \
      --value logical
  5. After modifying these parameters, restart the database instance:

    az postgres flexible-server restart \
      --name AZURE_SERVER_NAME \
      --resource-group AZURE_RESOURCE_GROUP

Configure Network Access

Before the Linode Managed Database can connect to your Azure Database instance, ensure that the instance allows network access from the Linode Managed Database.

  1. Navigate to the Settings > Networking page for the instance. Make sure that the Public access option is checked.

    Azure Database for PostgreSQL Networking page showing the Public access option enabled.

  2. In the list of firewall rules, add a rule to allow access to your Linode Managed Database. Specify a name for the firewall rule. Enter the IP address of your Linode Managed Database as both the Start IP address and the End IP address:

  3. Click Save at the top of the page.

  1. Determine if public network access is enabled:

    az postgres flexible-server show \
      --resource-group AZURE_RESOURCE_GROUP \
      --name AZURE_SERVER_NAME \
      --query "network.publicNetworkAccess"

    If the output is "Enabled", skip the following command:

    "Enabled"
  2. If the output is "Disabled", use the following command to enable public network access:

    az postgres flexible-server update \
      --resource-group AZURE_RESOURCE_GROUP \
      --name AZURE_SERVER_NAME \
      --public-network-access Enabled
  3. Add a firewall rule allowing access from your Linode Managed Database. Replace DEST_IP with the IP address from Logical Replication to a Linode Managed PostgreSQL Database (e.g., 172.232.188.122):

    az postgres flexible-server firewall-rule create \
      --resource-group AZURE_RESOURCE_GROUP \
      --name AZURE_SERVER_NAME \
      --rule-name allow-linode-managed-database \
      --start-ip-address DEST_IP \
      --end-ip-address DEST_IP
  4. Verify the firewall rules:

    az postgres flexible-server firewall-rule list \
      --resource-group AZURE_RESOURCE_GROUP \
      --name AZURE_SERVER_NAME \
      -o table
    EndIpAddress     Name                           ResourceGroup    StartIpAddress
    ---------------  -----------------------------  ---------------  ----------------
    172.235.145.182  allow-linode-managed-database  pg-repl-rg       172.235.145.182

With network access configured, your Linode Managed Database can reach the Azure Database instance during the subscription creation step in Logical Replication to a Linode Managed PostgreSQL Database.

Create a Replication User

While logical replication can technically be performed using the primary database user, it’s best practice to create a dedicated replication user. This user should have the REPLICATION privilege and SELECT access only to the tables being published.

Follow the steps below to create this dedicated user on your Azure Database instance.

  1. Connect to your source PostgreSQL instance using the psql client. Replace SOURCE_HOST (e.g., source-database.postgres.database.azure.com), SOURCE_PORT (e.g., 5432), SOURCE_USER (e.g., azureadmin), and SOURCE_DB (e.g., postgres) with your own values. You can find the connection details on the Settings > Connect page of your Azure Database instance.

    psql \
      -h SOURCE_HOST \
      -p SOURCE_PORT \
      -U SOURCE_USER \
      -d SOURCE_DB

    When prompted, enter your SOURCE_PASSWORD (e.g., thisismysourcepassword).

  2. Run the following commands from the source psql prompt. Replace REPL_USER (e.g., linode_replicator) and REPL_PASSWORD (e.g., thisismyreplicatorpassword) with your own values. For simplicity, this example assumes a public schema and three sample tables (customers, products, and orders). Replace the table names with your actual schema as needed.

    Source psql Prompt
    CREATE ROLE REPL_USER
           WITH REPLICATION
           LOGIN PASSWORD 'REPL_PASSWORD';
    GRANT SELECT ON customers, products, orders TO REPL_USER;
    CREATE ROLE
    GRANT

    You can also grant privileges on all tables with the following command:

    Source psql Prompt
    GRANT SELECT ON ALL TABLES IN SCHEMA public TO REPL_USER;
    GRANT

The newly created user is referenced by the Linode Managed Database when creating the subscription in Logical Replication to a Linode Managed PostgreSQL Database.

Create a Publication

A publication defines which tables and changes (e.g., INSERT, UPDATE, and DELETE) should be streamed to the subscriber. At least one publication is required for logical replication, and the subscriber must have matching tables with compatible schemas for replication to succeed.

  1. While still connected to your source database via the psql client, use the following command to create a publication. Replace PUBLICATION_NAME (e.g., my_publication) and the specific tables you want to replicate (e.g., customers, products, and orders):

    Source psql Prompt
    CREATE PUBLICATION PUBLICATION_NAME FOR TABLE customers, products, orders;
    CREATE PUBLICATION

    You can also create a publication for all tables in the database:

    Source psql Prompt
    CREATE PUBLICATION PUBLICATION_NAME FOR ALL TABLES;
  2. Run the following command to view all existing publications:

    Source psql Prompt
    SELECT * FROM pg_publication_tables;
        pubname     | schemaname | tablename |                       attnames                        | rowfilter
    ----------------+------------+-----------+-------------------------------------------------------+-----------
     my_publication | public     | customers | {customer_id,name,email,created_at}                   |
     my_publication | public     | products  | {product_id,name,price,created_at}                    |
     my_publication | public     | orders    | {order_id,customer_id,product_id,quantity,created_at} |
    (3 rows)
  3. Type \q and press Enter to exit the source psql shell.

Your Azure source database is now ready for logical replication. Return to Logical Replication to a Linode Managed PostgreSQL Database to configure the Linode Managed Database and create the subscription.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.