How to Allow Azure AD-Authenticated Users to Interact with PostgreSQL FDW Tables through User Mapping

van der Stelt, Gideon 0 Reputation points
2025-04-01T15:21:16.35+00:00

I am using PostgreSQL Foreign Data Wrappers (FDW) in an Azure Database for PostgreSQL - Flexible Server environment. My users authenticate to the database using Azure AD token-based authentication.

The issue arises when these users attempt to run UPDATE queries on a foreign table (using postgres_fdw). PostgreSQL requires a USER MAPPING for each user on the foreign server, which typically includes a username and password. However, since my users authenticate via Azure AD tokens, I cannot provide a static password in the user mapping.

Additionally, because this is an Azure Flexible Server instance, I do not have SUPERUSER privileges, meaning I cannot set password_required = false on the foreign server.

Users connect to the database server using PGAdmin.

Question:

How can I enable Azure AD-authenticated users who connect through PGAdmin to update foreign tables via FDW without requiring a static password in the user mapping?

Any insights would be greatly appreciated!

Azure Database for PostgreSQL

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.