The error message you are encountering (Msg 22902) indicates that the caller is not authorized to enable Change Data Capture (CDC) on the Azure SQL Database. Here are some steps and considerations to address this issue:
- Database Permissions: Ensure that the user account you are using has the necessary permissions. Even though you are using a server-level admin login, it is important to verify that the login has appropriate permissions on the specific database where you are trying to enable CDC. The
db_ownerrole is required to enable CDC for Azure SQL Database. - Check Database Tier: Confirm that your database is on a supported service tier for CDC. CDC is supported for any service tier within the vCore-based purchasing model, and for databases in the DTU purchasing model, it is supported for databases in the S3 tier or higher. If your database is in a lower tier (Basic, S0, S1, S2), you will not be able to enable CDC.
- Use the Correct Database Context: Make sure you are connected to the specific database (not the master database) when executing the
EXEC sys.sp_cdc_enable_db;command. You should execute this command in the context of the database you want to enable CDC for. - Check for Existing
cdcSchema/User: Ensure that there is no existing schema or user namedcdcin the database, as this could prevent CDC from being enabled. If such a schema or user exists, you will need to drop or rename it before enabling CDC. - Re-try with Different Accounts: If you have other accounts with
db_ownerprivileges, try using those to see if the issue persists.
If you have verified all of the above and are still encountering issues, consider reaching out to Azure support for further assistance.
References: