Hello Sam Chen,
The error occurs because the roles assigned (Owner, Contributor, Cosmos DB Operator, DocumentDB Account Contributor) are control-plane roles, which don't grant the data-plane permissions required by Cosmos DB Table API.
Specifically, the action Microsoft.DocumentDB/databaseAccounts/readMetadata needs a built-in data role.
To fix this, assign one of the Cosmos DB built-in data roles at the account scope (/) to the user or managed identity:
- Cosmos DB Built-in Data Reader (Role ID:
00000000-0000-0000-0000-000000000001) - Cosmos DB Built-in Data Contributor (Role ID:
00000000-0000-0000-0000-000000000002)
For example, using Azure CLI:
az cosmosdb sql role assignment create \
--resource-group <resource-group> \
--account-name <cosmos-account> \
--scope "/" \
--principal-id <user-object-id> \
--role-definition-id "00000000-0000-0000-0000-000000000002"
Make sure to replace placeholders with your actual values.
This approach grants the necessary data-plane permissions and resolves the 403 Forbidden RBAC error.
For more details, refer these MS Documentation:
- Data plane security reference - Azure Cosmos DB for Table | Microsoft Learn
- Connect using role-based access control and Microsoft Entra ID - Azure Cosmos DB for Table | Microsoft Learn
Hope this helps! Let us know if any further queries.
If this answers your query, do click Accept Answer and Yes for was this answer helpful, which may help members with similar questions.