I have an azure function to read and update the cosmos document . I enabled the identity and assigned the following roles to azure function identity(service principal). Somehow I’m seeing the following exception. Could you please let me know the build in RBAC roles i should have to assign.
- DocumentDB Account Contributor
- Cosmos DB Account Reader Role
- Contributor
Exception Details:
Request is blocked because principal does not have required RBAC permissions to perform action [Microsoft.DocumentDB/databaseAccounts/readMetadata] on resource .
2
Answers
To read and update the
Cosmos DB Account
using Azure Function identity(service principal)
, it may require theDocumentDB Account Contributor role
. With this role, you can perform the following actionsWhen I attempt to update a
Cosmos DB Account
using aService Principal
with the Cosmos DB Account Reader Role, I encounter the following error.To resolve the issue, kindly assign the DocumentDB Account Contributor role to perform
read
andupdate
operations in theCosmos DB account
.I’m able to update the
Cosmos DB Account
after assigning the role.If you still encounter the same error, make sure to assign the role to the correct service principal
(Azure Function system identity)
Refer the Ms Doc for Azure Cosmos DB account
You need to configure RBAC for the data plane not the management plane:
There are two built-on roles but you could also create custom roles:
You can use Az Powershell, Az CLI, or the ARM API to create role asisgnment.
AzCLI sample: