Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted

Suman Nenavath 1 Reputation point
2021-02-27T00:09:03.96+00:00

Failed to execute stored procedure bulkImport for container T-Container:
Message: {"Errors":["Encountered exception while executing function. Exception = Error: {\"Errors\":[\"Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.\"]}\r\nStack trace: Error: {\"Errors\":[\"Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.\"]}\n at callback (script.js:35:18)\n at Anonymous function (script.js:687:29)"]}
ActivityId: 74a4fa59-fada-48d6-9cd9-cf3efd50c9b9, Request URI: /apps/1aa1502b-e470-4fc3-8e16-4233c9ad26a4/services/791ea96b-7901-49aa-b9be-9a332dee4e6a/partitions/9211bd50-b5de-45b6-9cf0-3129a7fc1643/replicas/132586158016382373p/, RequestStats:
RequestStartTime: 2021-02-27T00:01:31.2776055Z, RequestEndTime: 2021-02-27T00:01:31.2776055Z, Number of regions attempted:1
ResponseTime: 2021-02-27T00:01:31.2776055Z, StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-eastus1-fd64.documents.azure.com:1412/apps/1aa102b-e470-4fc3-8e16-423c9ad26a4/services/791ea96b-7901-49aa-b9be-9a332dee4e6a/partitions/9211d50-b5de-45b6-9cf0-319a7fc1643/replicas/13258158016382373p/, LSN: 236, GlobalCommittedLsn: 236, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 412, RequestCharge: 3, ItemLSN: -1, SessionToken: -1#236, UsingLocalLSN: False, TransportException: null, ResourceType: StoredProcedure, OperationType: ExecuteJavaScript
, SDK: Microsoft.Azure.Documents.Common/2.11.0

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,491 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mark Brown - MSFT 2,766 Reputation points Microsoft Employee
    2021-02-27T00:54:32.27+00:00

    Stored procedures are scoped to a single partition key value. You cannot use stored procedures to do bulk inserts into more than one logical partition key at a time.

    A better option may be to use bulk mode in the .NET or Java SDK. This can be set in the connection options for the cosmos client.

    0 comments No comments