How to achieve blue/green upgrades in Azure Database for PostgreSQL flexible server

Yash Gupta 20 Reputation points
2025-06-09T09:54:19.9866667+00:00

Hi Greetings,

I was looking at options that can help us achieve a blue/green upgrades pattern for updating compute configs for our Azure Database for PostgreSQL flexible server, I had explored read replica promotion to primary and promotion to standalone server, but we have a few concerns with it,

1) Promotion of read replica to primary: we aim to create a read replica with updated configs (ex, upgraded compute size), then promote it to primary, utilize virtual endpoints to avoid updating applications using these endpoints, the issue here is Azure requires the replica config to match the primary server in order to promote to primary so we can't promote a replica with updated config.
2) Promotion to Standalone Server: create replica with updated config, promote to independent server, but this leads to a change in the server endpoint, and since we can not rename the server this change is unavoidable, and would require updating existing applications.

Can you please suggest a way to achieve blue/green deployment, or if you have any other related information regarding safe upgrades of Azure Database for PostgreSQL flexible server it would be helpful.
Thanks in advance !

Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. Amira Bedhiafi 32,756 Reputation points Volunteer Moderator
    2025-06-09T14:40:28.6033333+00:00

    Hello Yash !

    Thank you for posting on Microsoft Learn.

    Azure mandates that a replica must match the configuration of its primary (compute/storage) to be promotable to primary. This prevents blue/green promotion with config changes on the replica.

    Also don't forget that server names/hostnames are immutable, and promotion to standalone results in a new FQDN can require app reconfiguration.

    You can’t directly achieve blue/green inside Azure PostgreSQL Flexible Server, but you can orchestrate it externally.

    How ?

    You can use a Client-Agnostic connection endpoint (proxy or DNS indirection).

    So you need to place a PgBouncer instance (or HAProxy/Nginx with stream module) in Azure (VM, container, or App Service).

    In this way, the clients connect to PgBouncer using a custom DNS name and then it routes traffic to either the blue (current) or green (new) PostgreSQL server.

    Don't forget that :

    • You can’t promote a read replica with a different compute config
    • You can’t rename PostgreSQL servers in Azure
    • You can’t clone or swap the primary/replica roles like traditional on-prem setups
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.