Azure PostgreSQL connection logging is disabled

Enable Azure PostgreSQL connection logs to investigate connection attempts and successful connections.

Description

On Flexible Server, log_connections can record attempts that reach the server and successful client authentication and authorization.

Potential impact

Without these records, it is harder to trace application connection problems or unexpected use of an account. Investigating SQL statements and data changes requires separate auditing.

Remediation

Choose the connection logging value supported by your server version. The example uses value: 'on'. Open a new authorized connection and find its record at the log destination. Set retention and reader access, and enable disconnection logging separately if you also need session end times.

Examples

The first excerpt targets retired Single Server. In the second, MyDBServer1 is a separately prepared Flexible Server. Parent declarations and data migration are omitted.

Before

bicep
resource MyDBServer1_log_connections 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
  parent: MyDBServer1
  name: 'log_connections'
  properties: {
    value: 'off'
  }
}

After

bicep
resource MyDBServer1_log_connections 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2024-08-01' = {
  parent: MyDBServer1
  name: 'log_connections'
  properties: {
    source: 'user-override'
    value: 'on'
  }
}

References