【问题标题】:Writing to azure cosmos db from azure functions does not create any entities从 azure 函数写入 azure cosmos db 不会创建任何实体
【发布时间】:2018-04-19 15:23:57
【问题描述】:

我正在尝试从 Azure 函数脚本写入 cosmosDB 服务。 该函数正确执行,在我的 cosmosDB 指标中,我可以看到进来的请求。新表和集合也在 cosmosDB 中创建,因此请求正在通过。

但是,没有在集合中创建新实体。我是否忘记了什么或理解错误?

index.js

module.exports = function (context, message) {
    context.bindings.testDocument = JSON.stringify({ 
        name: "name",
        duedate: "duedate",
        task: "task"
    });
    context.log('context binding set');
    context.done();
};

function.json

{
 "bindings": [
{
  "type": "eventHubTrigger",
  "name": "message",
  "direction": "in",
  "path": "samples-workitems",
  "connection": "MAP-hub_events_IOTHUB",
  "cardinality": "one",
  "consumerGroup": "$Default"
},
{
  "type": "documentDB",
  "name": "testDocument",
  "databaseName": "testDataBase",
  "collectionName": "testCollection",
  "createIfNotExists": true,
  "connection": "raw-data-storage_DOCUMENTDB",
  "direction": "out"
}
],
"disabled": false
}

数据库

创建的数据库和集合的屏幕截图:

指标

cosmosDB 指标的屏幕截图:

【问题讨论】:

标签: azure azure-functions azure-cosmosdb


【解决方案1】:

您有一个使用 表模型 的 Cosmos DB 帐户。 Table 模型在您可以使用 SQL API 发送给它的文档中存在一些架构限制(Cosmos DB Output binding 使用 SQL SDK 来持久化文档)​​。

如果要使用输出绑定,请尝试使用 Cosmos DB SQL 类型的帐户。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 2021-01-05
    • 2021-06-17
    相关资源
    最近更新 更多