Share via

Azure PostgreSQL database was unavailable in maintenance window

Adrian Pitic 20 Reputation points
2026-05-27T12:17:46.3733333+00:00

Hello,

An Azure PostgreSQL database becomes unavailable during maintenance period even if the High Availability featured is enabled. During the maintenance the standby server does not become active. The database becomes available only after the maintenance is finished.
It would be perfect if the database stays available during the server maintenance. How can I achieve this?

Thank you!

Azure Database for PostgreSQL

Answer accepted by question author

Pilladi Padma Sai Manisha 8,730 Reputation points Microsoft External Staff Moderator
2026-05-29T06:46:12.3733333+00:00

Hi Adrian Pitic,

thanks for the details.

What’s happening here is expected behavior for Azure Database for PostgreSQL maintenance, even when you have High Availability enabled. During a planned maintenance:

• Azure patches the standby first

• then triggers a planned failover so the newly-patched standby becomes primary

• finally patches the former primary

That failover step does cause a brief interruption (typically a few seconds), and if the standby isn’t healthy at maintenance time, Azure will patch the primary directly—resulting in the few-minute outage you saw. You can’t completely avoid downtime, but you can minimize it. Here’s what you can do:

  1. Verify and maintain a healthy standby
    • Make sure you’re using zone-redundant HA (multiple availability zones)
    • Monitor the standby’s replication lag and health so it’s ready to take over
  2. Use Flexible Server with a custom maintenance window
    • Set a window during your off-peak hours
    • Custom windows only apply to regular updates—critical or emergency patches may override them
  3. Set up Azure Service Health notifications
    • You’ll get alerts 5 days before regular maintenance and when it starts/completes
  4. Add retry logic in your application
    • Handle transient failures during failover gracefully
  5. If you need truly near-zero downtime
    • Consider creating a read replica in another region or a Hyperscale (Citus) cluster
    • You can patch the replica, promote it, and switch your applications over with minimal disruption

Let me know if you’d like more detail on any of these steps or help verifying your HA/standby health!

Reference docs:

• Managed schedule maintenance for Azure PostgreSQL Flexible server

https://supportability.visualstudio.com/AzureDBPostgreSQL/_wiki/wikis/AzureDBPostgreSQL/541943/Azure%20Database%20For%20PostgreSQL/Azure%20DB%20for%20PostgreSQL%20-%20Flexible%20Server/Troubleshooting%20Guides/Availability%20and%20Connectivity/Managed%20schedule%20maintenance%20for%20Azure%20PostgreSQL-%20Flexible%20server

• Azure Database for PostgreSQL (PaaS) – High availability architecture

https://learn.microsoft.com/azure/postgresql/overview?wt.mc_id=knowledgesearch_inproduct_azure-cxp-community-insider#architecture-and-high-availability

• Scheduled maintenance in Azure Database for PostgreSQL flexible servers

https://docs.microsoft.com/azure/postgresql/flexible-server/concepts-maintenance?source=recommendations

• Planned maintenance in Azure Databases for PostgreSQL - Single Server

https://docs.microsoft.com/azure/postgresql/concepts-planned-maintenance-notification

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Vinodh247-1375 43,021 Reputation points Volunteer Moderator
    2026-05-27T15:59:13.4433333+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    This is expected behaviour in Azure db for PostgreSQL (especially Single Server and even Flexible Server in certain maintenance scenarios). High availability there is not zero-downtime failover during planned maintenance; the standby is for failover on failure, not for seamless patching. During maintenance, Azure applies updates and restarts the primary, and the standby is not promoted automatically, causing a brief outage. To achieve near-zero downtime, you need to move beyond built-in HA: use zoneredundant Flexible Server (latest tier) with planned failover support, or implement application-level resiliency (retry logic + connection pooling), or use read replicas with manual/controlled failover, or go further with multi-region active-active patterns (for example, using logical replication or Citus). In short, native HA alone does not guarantee maintenance-time availability, you need architectural mitigation.

    Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the reply was helpful. This will be benefitting other community members who face the same issue.

    Was this answer helpful?

    0 comments No comments

Your answer

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