Solution skill
PartitionKey value must be supplied for this operation
Complete solution
Diagnoses the Cosmos DB error 'PartitionKey value must be supplied for this operation' when calling stored procedures or operations on a partitioned collection. Use when an agent sees this from the .NET SDK or any DocumentDB client. Covers passing RequestOptions with the partition key and making sure the document carries the partition key property. Not for throughput or auth errors.
PartitionKey value must be supplied for this operation
TL;DR
You are calling a stored procedure (or another partition-scoped operation) without saying which partition it belongs to. Pass the partition key in the request options, and make sure your documents actually carry the partition key property. One of those two is missing.
The error
PartitionKey value must be supplied for this operation.Fix it
- Pass the partition key with the call. In the .NET SDK that means RequestOptions carrying the key:
new RequestOptions { PartitionKey = new PartitionKey("[your-partition-key-value]") }. Expected: the stored procedure executes against the right partition. - Check that the document you are writing includes the partition key property the collection is partitioned on. Expected: the document has the property with a non-null value.
- Confirm the partition key path on the collection matches what your code sends. A collection partitioned on
/tenantIdneedstenantIdin the document, nottenant_id. Expected: the paths match exactly. - For stored procedures, remember they run inside one partition. There is no cross-partition stored procedure call. Expected: the procedure logic stays within a single partition key value.
- Retry the operation. Expected: it succeeds.
When to use this
- An agent sees "PartitionKey value must be supplied for this operation" from Cosmos DB or the DocumentDB SDK.
- Stored procedure calls against a partitioned collection.
When NOT to use this
- 429 throttling or RequestRateTooLarge. Those are throughput, not partition keys.
- 401 or 403 auth errors. Those are keys and permissions.
Compatibility
- Azure Cosmos DB (SQL API), DocumentDB .NET SDK and equivalents.
Variant phrasings
- "PartitionKey value must be supplied"
- Stored procedure failures on partitioned collections
Root cause
Partitioned collections route every operation by the partition key. A stored procedure executes transactionally inside one partition, so the service refuses to run it without knowing which partition you mean. The two classic misses are forgetting the RequestOptions and writing documents that lack the partition key property entirely.
Edge cases
- Migrating from a single-partition (old DocumentDB) collection to partitioned: old code has no partition key anywhere and every call needs updating.
- The partition key value is case-sensitive. "TenantA" and "tenanta" are different partitions.
Evidence
Stack Overflow accepted answers (mirrored with the accepted answer marked) for executing stored procedures against a partitioned DocumentDB/Cosmos DB collection: the fix is passing the partition key in RequestOptions and ensuring documents carry the partition key property. The accepted answer pattern is RequestOptions with PartitionKey set to the document's partition key value. Multiple related threads confirm the same root cause: the operation is partition-scoped and the key was not supplied.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_I1EMh1evHph4qEVN8B5CYA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">PartitionKey value must be supplied for this operation <span>— Vectle</span></a>