I am working on Bulk insert stored procedure in Cosmos database using document client but the challenge that I am facing is, I need to insert documents in bulk that may have different partition keys.
Is there any way to achieve it?
I am currently using the below code:
Uri uri = UriFactory.CreateStoredProcedureUri("test-db", "test-collection", "sp_bulk_insert");
RequestOptions options = new RequestOptions { PartitionKey = new PartitionKey("patient")};
var result = await _client.ExecuteStoredProcedureAsync<string>(uri, options , patientInfo, pageInfo);
return result;
But I also have pageInfo object having partition key: "page" but given PartitionKey in RequestOptions is "patient" that is the partition key of patientInfo object
When I am trying to execute the SP it is giving following error:
Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted