Automating Session Termination for Expired Access Tokens in Azure PostgreSQL Flexible Server

Sai Praneeth Eranti 190 Reputation points
2025-03-31T13:15:03.44+00:00

Managing an Azure PostgreSQL Flexible Server, an issue has arisen where user sessions in tools like Azure Data Studio (ADS) and pgAdmin are not automatically terminated upon access token expiration. The goal is to find a way to automate the termination of these sessions for enhanced security and compliance, rather than creating a custom script and utilizing Automation Accounts.

Are there any default server parameters available that can be configured to achieve this?

Errors in the logs include:

FATAL | The access token has expired. Please acquire a new token and retry
FATAL | no pg_hba.conf entry for host "<IP>", user "<AAD Group>", database "postgres", no encryption | <ServerName>
Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. PratikLad 720 Reputation points Microsoft External Staff
    2025-04-02T06:34:15.15+00:00

    Hi Sai Praneeth Eranti

    Are there any default server parameters available that can be configured to terminate the session once access token expiration.

    Currently, Azure Database for PostgreSQL Flexible Server does not offer a built-in server parameter to automatically terminate user sessions upon access token expiration.

    Does above answer still valid to exclude from server logs ?

    AFAIK Currently, Azure Database for PostgreSQL Flexible Server does not provide a built-in mechanism to exclude specific Azure Active Directory (AD) groups from server logs. However, you can manage and filter logs after they have been collected.

    It's important to note that while this method enables you to filter logs during analysis, it doesn't prevent the initial logging of events related to specific AD groups. As of now, there isn't a feature within Azure Database for PostgreSQL Flexible Server to exclude logging for specific AD groups at the source.

    In Azure Postgres SQL you can create alert based on custom log queries as below, and use it for your requirement to avoid getting alerts for particular error message


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And,

    if you have any further query do let us know.

    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.