An Azure managed PostgreSQL database service for app development and deployment.
Hi @Tobias Runesson -
Taking your questions in order.
Identifying what is blocking it
PostgreSQL will usually tell you. From Dropping Roles:
"If
DROP ROLEis attempted while dependent objects still remain, it will issue messages identifying which objects need to be reassigned or dropped."
So instead of trying to infer dependencies from catalog queries, reproduce the failure in psql and read the error. PostgreSQL will often tell you exactly what is still blocking the role from being removed.
Removing the remaining dependencies
The part that usually catches is that REASSIGN OWNED by itself is often not enough.
From the same PostgreSQL documentation:
"
DROP OWNEDalso takes care of removing any privileges granted to the target role for objects that do not belong to it. BecauseREASSIGN OWNEDdoes not touch such objects, it's typically necessary to run bothREASSIGN OWNEDandDROP OWNED(in that order!)"
The same page also notes that neither command reaches into other databases, so both need to be run in each one:
-- Run in each database where the role may own objects or hold privileges
REASSIGN OWNED BY "entra_admin_role" TO "replacement_role";
DROP OWNED BY "entra_admin_role";
Once that has been done everywhere, including the postgres database, retry the administrator removal.
If a subsequent DROP ROLE still fails, PostgreSQL should identify the remaining dependency.
Whether manual cleanup is supported
The closest the docs come is in Microsoft Entra authentication in Azure Database for PostgreSQL flexible server, under Limitations and considerations:
"If you delete a Microsoft Entra principal from Microsoft Entra ID, the principal remains as a PostgreSQL role... Database administrators need to transfer ownership and drop roles manually."
That describes a different scenario, so I would not treat it as direct guidance for removing an Entra administrator. What it does show is that manually transferring ownership and cleaning up PostgreSQL roles is expected practice on this service rather than something unsupported.
Help make this community better for everyone: if this answer resolved your issue, please accept it or leave an upvote. If not, share more details in a comment so we can continue the discussion and find the right solution.