You cannot remove stale AAD principals directly on azure PostgreSQL Flexible Server once the Managed Identity is deleted, since the internal mapping remains orphaned. The only reliable workaround is to recreate the server or restore from a backup prior to the mapping.
Azure PostgreSQL Flexible server does not expose pgaadauth_drop_principal() or any system catalog access to manually clean up orphaned entries. As of now, microsoft does not provide a direct method to remove stale AAD principals in Flexible Server once the associated identity is gone.
Limited but recommended actions:
- Open a Microsoft support ticket -> request backend cleanup of the stale principal (they can run internal scripts).
As a workaround, recreate the Flexible Server or restore to a new one and reapply valid principals.
There is currently no user-accessible command or API to remove the orphaned AAD principal from Flexible Server.