gpt4 book ai didi

Azure Function CosmosDB 触发器返回编码数据?

转载 作者:行者123 更新时间:2023-12-03 03:00:00 31 4
gpt4 key购买 nike

我编写了一个简短的 Azure 函数,用于简单地从 CosmosDB 更改源触发器中获取数据。

但是,看起来它返回某种形式的编码数据。

例如

{
"_id" : ObjectId("5ad8db107dfa95101430ab94"),
"id" : "task123",
"type" : "genera123l",
"information" : "some task"
}

如果上述文档是在我的 cosmos 数据库中创建的,

public static void Run(IReadOnlyList<Document> documents, TraceWriter log)
{
if (documents != null && documents.Count > 0)
{
log.Info("Documents modified " + documents.Count);
log.Info("First document Id " + documents[0].Id);
}
}

上面的代码将打印

2018-04-19T19:28:23.899 [Info] Documents modified 1
2018-04-19T19:28:23.899 [Info] First document Id NWFkOGRiMTA3ZGZhOTUxMDE0MzBhYjk0

而不是

2018-04-19T19:28:23.899 [Info] Documents modified 1
2018-04-19T19:28:23.899 [Info] First document Id task123

这是预期的输出。我在这里缺少某种配置吗?

看起来没有 CosmosDB 或 Azure Function App 的文档解决这个问题:(

谢谢

最佳答案

我假设您使用 Azure CosmosDB MongoDb API 进行输入绑定(bind)。

请尝试使用Azure CosmosDB SQL API。详细步骤可以引用这个guide 。然后就可以得到预期的答案了。更多信息请引用这个link .

Don't use Azure Cosmos DB input or output bindings if you're using MongoDB API on a Cosmos DB account. Data corruption is possible.

enter image description here

关于Azure Function CosmosDB 触发器返回编码数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49928894/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com