In the previous post, we troubleshoot the network-related issue connecting to Azure Cosmos DB, where the error messages are clear, leading us directly to the root cause. This article discusses the IAM-related issues where the error messages may look confusing. Long story short,
- For read access to Azure Cosmos DB, the user needs Cosmos DB Account Reader Role
- For read/write access, the user needs DocumentDB Account Contributor
Read Access for Querying Azure Cosmos DB
We granted the user the Reader role on the Cosmos DB so he could read the database. However, the user encountered the errors below when trying to select data via Data Explorer in the Azure Portal:
Authorization header doesn't confirm to the required format. Please verify and try again. ActivityId: [redacted], Microsoft.Azure.Documents.Common/2.14.0

Honestly, at first sight I couldn’t link this Authorization header format error to IAM. It took us a while to realize that the Reader role is insufficient for DB data access. The issue was resolved after the user was granted the Cosmos DB Account Reader Role.
Read/Write Access
To gain read/write access, you will need the DocumentDB Account Contributor role. If the user only has Cosmos DB Account Reader Role and tries to insert a record into the container, he will see the error below:
Create document failed The input authorization token can't serve the request. The wrong key is being used or the expected payload is not built as per the protocol. For more info: <https://aka.ms/cosmosdb-tsg-unauthorized>. Server used the following payload to sign: 'post docs dbs/SampleDB/colls/SampleContainer mon, 24 mar 2025 22:00:52 gmt ' ActivityId: [redacted], Microsoft.Azure.Documents.Common/2.14.0

Again, the error tells you that the wrong key was used, but gives little clue regarding IAM. In fact, this issue can be resolved by granting the user the DocumentDB Account Contributor role.
Verify Your Permissions by Revealing the DB Keys
If you have access to the DB data, you should be able to reveal the read-only or read-write DB keys in the Azure Portal. The grayed-out icon indicates that you do not have the corresponding permissions or roles.


