【问题标题】:Logic App > Cosmos PartitionKey Not Matching Error逻辑应用 > Cosmos PartitionKey 不匹配错误
【发布时间】:2020-11-02 20:44:41
【问题描述】:

我害怕把它放在那里,因为它应该很容易,而且我面临与帖子hereherehere 相同的问题,我尝试了每个答案都无济于事.以下是输入的当前结果输入(已编辑)和相关 CodeView。

结果

{
"method": "post",
"headers": {
    "x-ms-documentdb-raw-partitionkey": "\"2020\""
},
"path": "/dbs/xxxx/colls/smtp/docs",
"host": {
    "connection": {
        "name": "/subscriptions/..."
    }
},
"body": {
    "category": [
        [
            "cat facts"
        ]
    ],
    "email": "example@test.com",
    "event": "processed",
    "id": "yada",
    "partitionKey": "\"2020\"",
    "sg_event_id": "yada yada",
    "sg_message_id": "yada",
    "smtp-id": "yada",
    "timestamp": 1604345542
}
}

代码视图

{
"inputs": {
    "body": {
        "category": [
            "@items('For_each')['category']"
        ],
        "email": "@items('For_each')['email']",
        "event": "@items('For_each')['event']",
        "id": "@items('For_each')['sg_message_id']",
        "partitionKey": "\"@{formatDateTime(utcNow(),'yyyy')}\"",
        "sg_event_id": "@items('For_each')['sg_event_id']",
        "sg_message_id": "@items('For_each')['sg_message_id']",
        "smtp-id": "@items('For_each')['smtp-id']",
        "timestamp": "@items('For_each')['timestamp']"
    },
    "headers": {
        "x-ms-documentdb-raw-partitionkey": "\"@{formatDateTime(utcNow(),'yyyy')}\""
    }
}

我得到的错误是通常的错误 - 从文档中提取的 PartitionKey 与标题中指定的不匹配

我现在看不到我在这里缺少什么。

谢谢大家。

【问题讨论】:

  • 您的容器中定义的分区键路径是什么?如果你转到 Azure 门户 > 数据资源管理器,选择容器并转到设置,是否显示 /partitionKey
  • 真的很简单——/年

标签: azure-cosmosdb azure-logic-apps


【解决方案1】:

首先,作为 Matias cmets,检查您的分区键路径。

然后,在您的文档中将此代码 "partitionKey": "\"@{formatDateTime(utcNow(),'yyyy')}\"", 更改为 "partitionKey": "@{formatDateTime(utcNow(),'yyyy')}",

它在我这边运行良好:

【讨论】:

  • @LeeAlderdice 由于你的分区键路径是'/year',你需要更改"partitionKey": "\"@{formatDateTime(utcNow(),'yyyy')}\"", to "year": "@{formatDateTime(utcNow(),'yyyy')}",
  • 我觉得有点傻,但要感谢您的宝贵时间。现在要解决一个新错误,但至少解决了这个错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-18
  • 2021-03-09
  • 2016-10-24
  • 1970-01-01
  • 1970-01-01
  • 2021-11-07
相关资源
最近更新 更多