Postgres 16 - 2BP01: role "PROD-infra-dt-sp cannot be dropped because some objects depend on it

Dhivyagrace Godwin 0 Reputation points
2025-02-18T22:20:07.63+00:00

When trying to delete the SP role after creating database and schemas, it throws error. However the same command works fine in postgres15. How do we resolve this?

az postgres flexible-server ad-admin delete \
 --yes \
 --resource-group ${POSTGRES_SERVER_RESOURCE_GROUP} \
 --server-name ${POSTGRES_SERVER_NAME} \
 --object-id ${DB_PROVISIONING_SERVICE_PRINCIPAL_OBJECT_ID}

ERROR: (AadAuthPrincipalDropFailed) Failed to drop Azure AD Principal. Reason - 2BP01: role "PROD-infra-dt-sp" cannot be dropped because some objects depend on it.

Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. Sai Raghunadh M 2,640 Reputation points Microsoft Vendor
    2025-02-18T23:33:39.4366667+00:00

    Hi @Dhivyagrace Godwin

    Thanks for the Question and using Microsoft Q&A

    As per my understanding, you are facing error, when you are trying to delete the SP role after creating database and schemas.

    As roles can own database objects and can hold privileges to access other objects, dropping a role is often not just a matter of a quick [DROP ROLE] Any objects owned by the role must first be dropped or reassigned to other owners; and any permissions granted to the role must be revoked.

    Please refer to this Documentation that might help you: https://www.postgresql.org/docs/16/role-removal.html

    Hope this helps. Do let us know if you any further queries.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.