Reputation: 11661
I am developing a C# Azure Function and want to execute a stored procedure in Cosmos DB like the following:
string sprocName = "testSPROC";
int partitionId = contentJSON.partitionid;
RequestOptions requestOptions = new RequestOptions { PartitionKey = new PartitionKey(partitionId), EnableScriptLogging = true };
var sprocResponse = await client.ExecuteStoredProcedureAsync<Object>(
UriFactory.CreateStoredProcedureUri(databaseName, collectionName, sprocName),
contentJSON,
requestOptions);
The CosmosDB collection is partition by partitionid. But when I want to execute the stored procedure, it returns:
PartitionKey value must be supplied for this operation
Why?
Upvotes: 3
Views: 1950
Reputation: 11661
At the first glance everything looks fine but the order of the parameters passed to the SPROC and the request options is wrong. It has to be
var sprocResponse = await client.ExecuteStoredProcedureAsync<Object>(
UriFactory.CreateStoredProcedureUri(databaseName, collectionName, sprocName),
requestOptions,
contentJSON);
Then it works.
Upvotes: 4