azure - 如何使用 Azure 存储过程提供分区键

标签 azure stored-procedures azure-cosmosdb

我正在 azure Cosmos DB 中访问我的存储过程 API,但我正在取回消息

{
"code": "BadRequest",
"message": "Message: {\"Errors\":[\"PartitionKey extracted from document doesn't match the one specified in the header\"]}\r\nActivityId: afd48989-60b5-489d-95ce-e999fc5561c9, Request URI: /apps/497cb807-5f70-43d9-a68c-a742815f6016/services/fae8a265-85a1-4d9b-904e-7a996901d928/partitions/ecdbf51b-d1f2-46d4-8b42-9ddbbf39aa1a/replicas/131818407837945845p, RequestStats: \r\nRequestStartTime: 2018-10-15T18:08:20.5929270Z, Number of regions attempted: 1\r\n, SDK: Microsoft.Azure.Documents.Common/2.1.0.0"
}

我知道我需要提供分区 key ,但我不确定如何。是在体内吗?作为标题提供?我在 postman 中尝试过这两种方法,但没有成功。使用 Postman,您将如何格式化请求以将分区键发送到存储过程?

我尝试过的示例(针对 POST 请求)

  1. 尝试添加名为“PartitionKey”且值为 51 的 header 。

  2. 尝试在原始正文中发送带有分区键 ["51"] 的数组,因为正文应该包含参数数组。

  3. 尝试了以下原始 json 正文

    {
        "PartitionKey": "51"
    } 
    

最佳答案

基于cosmos db Common REST request headers ,您需要使用x-ms-documentdb-partitionkey参数指定分区键。

{x-ms-documentdb-partitionkey : '51',...}

关于azure - 如何使用 Azure 存储过程提供分区键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52824322/

相关文章:

Azure RDP 在几秒钟内挂起

sql - MySQL 存储过程 : Boolean Logic in IF THEN

sql-server - 存储过程中 DROP 和 SELECT INTO 的默认架构

Azure CosmosDB : illegal characters in Document Id

Azure CosmosDb : Order-by item requires a range index

Azure SSL 配置

.net - Azure 产品和开发角色配置

azure - 从 CLI 问题 AZ 登录 - 自签名证书

mysql - 如何使用存储过程租用车辆

java - 如何使用JAVA从Azure Cosmos DB集合之一获取所有文档?