Closed stackoverflower closed 6 years ago
@stackoverflower stored procedures are already supported for partitioned collections. There are no changes in the programming API.
However the execution semantics are different. Stored procedures for partitioned collections must include a partition key and are scoped to the transaction boundary of a single partition key value.
@arramac can you show an example of how to include the partition key in the bulkDelete.js Stored Procedure sample?
When I try to save the bulkDelete.js SP in a partitioned collection I get the following error message:
Database Account: sktcosmosdb, Script: sktMultPart, Message: {"code":400,"body":"{\"code\":\"BadRequest\",\"message\":\"Replaces and upserts for scripts in collections with multiple partitions are not supported.\r\nActivityId: 685d2aaa-c509-4b76-ba1b-6181f4b40449, Microsoft.Azure.Documents.Common/1.17.101.1\"}","activityId":"685d2aaa-c509-4b76-ba1b-6181f4b40449"}
That same SP saves/runs fine in a single partition collection - so I'm missing something
@steve-torchia It's not an upsert inside the SP that's failing. It's upserting the SP itself: https://stackoverflow.com/questions/42299815/saving-testing-stored-procedures-triggers-maybe-user-defined-functions-for-p
+1 to @steve-torchia. BTW, the issue of upserting the SP itself has also been fixed. Closing this issue.
I just hit the 'upsert SP on partitioned collection' issue today. I would expect the fix to be server-side, right?
I just got the 'Upserts for scripts in collections with multiple partitions are not supported' error today. When will upsert stored procedures will be updated to support partitioned collections?
@eladkamin I had the same issue, using the ReplaceStoredProcedureAsync function as described in the stackoverflow thread from above worked perfectly for me
try
{
await _client.CreateStoredProcedureAsync(...);
}
catch(DocumentClientException dex) when (dex.StatusCode == HttpStatusCode.Conflict)
{
await _client.ReplaceStoredProcedureAsync(...);
}
Do you plan to update these stored procedures to support partitioned collections anytime soon?