How to run stored procedure for hierarchical partition container

Antra Sharma 41 Reputation points Microsoft Employee
2024-06-12T05:58:21.2433333+00:00

I am trying to run stored procedure from Azure Portal UI.
The container has hierarchical partition with two levels.
When trying to give the partition key value im providing input as json:
{"level1": "value1", "level2": "value2"}
This is leading to bad request, could anyone please suggest how to do it correctly

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

Accepted answer
  1. Oury Ba-MSFT 17,791 Reputation points Microsoft Employee
    2024-06-25T19:38:26.0166667+00:00

    @Antra Sharma

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer. Accepted answers show up at the top, resulting in improved discoverability for others.

    Issue: I am trying to run stored procedure from Azure Portal UI. The container has hierarchical partition with two levels. When trying to give the partition key value im providing input as json: {"level1": "value1", "level2": "value2"} This is leading to bad request, could anyone please suggest how to do it correctly

    Solution: I was able to figure out how to send hierarchical partition keys in stored proc using Azure portal. This is what worked for me: ["level1_value", "level2_value"]

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Rahul Gosavi 166 Reputation points
    2024-06-12T06:22:12.5266667+00:00

    When working with Azure Cosmos DB and its hierarchical partition key structure, providing partition key values requires a specific format. Based on the context, it seems you're trying to interact with a stored procedure and need to pass the partition key correctly.

    For hierarchical partition keys in Cosmos DB, you should provide the partition key values as an array rather than a JSON object. Here’s the correct way to format your partition key values:

    ["value1", "value2"]

    In this array, "value1" corresponds to the value for the first level of the partition key and "value2" corresponds to the value for the second level.

    If you are making a request using a tool like Azure Portal, Postman, or a custom application, you need to pass the partition key in this array format.

    Here’s how you can use this in various contexts:

    Example in Azure Portal:

    If you're using Azure Portal to interact with the stored procedure, you might need to specify the partition key in the request options. Make sure the partition key value is set correctly in the options section:

    { "partitionKey": ["value1", "value2"], "otherParameter": "someValue" }

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more