How do you go through PartitionKey to execute a stored procedure?

I am trying to execute a stored procedure in a partitioned collection (server-side separation) from the .net SDK (v1.6.3).

await client.ExecuteStoredProcedureAsync<string>(UriFactory.CreateStoredProcedureUri("db0", "collection0", "testsproc0"), storedProcedureParams);

I get the error "PartitionKey must be specified for this operation." In fact, I see this error in Azure Portal when I play with Script Explorer. However, I see no way to add PartitionKey. Is this a limitation for the API and shared collections right now, or am I missing something?

+6
source share
2 answers

you can pass the section key using the overloaded ExecuteStoredProcedureAsync method using RequestOptions. For instance,

 await client.ExecuteStoredProcedureAsync<DeviceSignal>( UriFactory.CreateStoredProcedureUri("db", "coll", "SetLatestStateAcrossReadings"), new RequestOptions { PartitionKey = new PartitionKey("XMS-001") }, sprocsParams); 
+6
source

I was getting a similar error and found that I had an invalid Partition Key Path when I created a collection of documents, as shown in the collectionDefinition.PartitionKey.Paths.Add("/LastName") below. My ExecuteStoredProcedure RequestOption does not match the field that I selected in new RequestOptions { PartitionKey = new PartitionKey("matchingLastNameSelectionHere") } . Hope this helps.

  private static async Task<DocumentCollection> CreateCollectionAsync(string dbLink, string id) { DocumentCollection collectionDefinition = new DocumentCollection { Id = id }; collectionDefinition.IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 }); collectionDefinition.PartitionKey.Paths.Add("/LastName"); return await _client.CreateDocumentCollectionAsync( dbLink, collectionDefinition, new RequestOptions { OfferThroughput = 400 }); } 

Execute code

 await client.ExecuteStoredProcedureAsync<DeviceSignal>(UriFactory.CreateStoredProcedureUri("db", "coll", "SetLatestStateAcrossReadings"), new RequestOptions { PartitionKey = new PartitionKey("matchingLastNameSelectionHere") }, sprocsParams); 
+1
source

All Articles