Hi Brenwell,
I’m sorry you’re still wrestling with this,it’s tricky when Azure’s superuser restrictions come into play, and I can see you’ve already gotten some great suggestions here. As a member of azure_pg_admin,
you should be able to delete that user, even without superuser rights or “ADMIN OWNER” status, as long as you clear any dependencies. let’s simplify it into a quick plan based on what’s worked for others with Azure Flexible Postgres:
- Check for Ownership: Connect as your azure_pg_admin user and see if the target user owns anything (databases or objects):
SELECT datname FROM pg_database WHERE datdba = (SELECT oid FROM pg_roles WHERE rolname = 'target_user');
For objects in a specific database:
SELECT nspname, relname FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE relowner = (SELECT oid FROM pg_roles WHERE rolname = 'target_user');
- Reassign If Needed: If you find any databases or objects, reassign them to your admin user:
- For objects (run in each affected database)
REASSIGN OWNED BY target_user TO your_admin_user;
- Drop Privileges: Clear any privileges tied to the user (run in each relevant database)
DROP OWNED BY target_user;
- Delete the User: Finally, drop the user
DROP ROLE target_user;
Since you’re in azure_pg_admin
, this should work—Azure gives you CREATEROLE,
which is enough to manage non-superuser roles like this, even if they don’t have an “ADMIN OWNER” tag. If you’re still getting a “permission denied” error, it might be a lingering dependency not caught above. Could you share the exact error (if any) , so I can double-check?
I hope this information helps. Please do let us know if you have any further queries.