Azure 是否可以使用1个outputbinding在cosmosDB中创建2个或更多文档

Azure 是否可以使用1个outputbinding在cosmosDB中创建2个或更多文档,azure,azure-functions,azure-cosmosdb,Azure,Azure Functions,Azure Cosmosdb,需要使用Azure函数在CosmosDB容器中创建2个文档,是否可以只使用一个out绑定?我认为另一种选择是使用Cosmos DB客户端 function.js { "bindings": [{ "name": "documents", "type": "cosmosDBTrigger", "direction": "in", "leaseCollectionName": "leases",

需要使用Azure函数在CosmosDB容器中创建2个文档,是否可以只使用一个out绑定?我认为另一种选择是使用Cosmos DB客户端

function.js

{
    "bindings": [{
            "name": "documents",
            "type": "cosmosDBTrigger",
            "direction": "in",
            "leaseCollectionName": "leases",
            "connectionStringSetting": "db_DOCUMENTDB",
            "databaseName": "db",
            "collectionName": "container1",
            "createLeaseCollectionIfNotExists": true
        },
        {
            "name": "inputDocumentOut",
            "type": "cosmosDB",
            "databaseName": "db",
            "collectionName": "container2",
            "createIfNotExists": false,
            "partitionKey": "{_partitionKey}",
            "connectionStringSetting": "db_DOCUMENTDB",
            "direction": "out"
        }
    ]
}
index.js

module.exports = async function(context, documents, inputDocumentOut) {

    context.log('JavaScript cosmos-trigger function processed a request.');

    if (!!documents && documents.length > 0) {
         // code ...
    }

    return {
        inputDocumentOut: [ doc1, doc2 ] // ???
    }

};


是的,只需向输出绑定传递一个文档数组,而不是单个文档:

module.exports = async function(context, documents) {

    context.log('JavaScript cosmos-trigger function processed a request.');
    var documentsToSave = [];
    if (!!documents && documents.length > 0) {
         // code ...
         // maybe call documentsToSave.push({.. some document schema to save..});
    }

    context.bindings.inputDocumentOut = documentsToSave;
};

是的,只需向输出绑定传递一个文档数组,而不是单个文档:

module.exports = async function(context, documents) {

    context.log('JavaScript cosmos-trigger function processed a request.');
    var documentsToSave = [];
    if (!!documents && documents.length > 0) {
         // code ...
         // maybe call documentsToSave.push({.. some document schema to save..});
    }

    context.bindings.inputDocumentOut = documentsToSave;
};

我认为您需要直接使用SDK调用来实现这一点我认为您需要直接使用SDK调用来实现这一点