Javascript 通过Azure功能用户界面删除CosmosDB文档

Javascript 通过Azure功能用户界面删除CosmosDB文档,javascript,azure-functions,azure-cosmosdb,document,function-binding,Javascript,Azure Functions,Azure Cosmosdb,Document,Function Binding,我一直在寻找,但找不到Javascript代码,该代码将使用门户UI删除Cosmos DB中的元素 目前,我一直在使用UI创建输入和输出绑定,并在我的index.js中进行读写: context.bindings.inputDocument context.bindings.outputDocument inputDocument提供了一个数组,然后我可以通过给outputDocument提供一个数组来创建新文档。我应该在index.js中编写什么样的Javascript代码,或者是否有其他绑

我一直在寻找,但找不到Javascript代码,该代码将使用门户UI删除Cosmos DB中的元素

目前,我一直在使用UI创建输入和输出绑定,并在我的index.js中进行读写:

context.bindings.inputDocument
context.bindings.outputDocument

inputDocument提供了一个数组,然后我可以通过给outputDocument提供一个数组来创建新文档。我应该在index.js中编写什么样的Javascript代码,或者是否有其他绑定来删除特定条目?

您可以在此处找到azure cosmosdb java脚本文档

Cosmos DB绑定对于您发现的读/写操作非常有用。对于删除操作,您需要手动使用Cosmos DB客户端

对于Javascript,请检查:

有关更多项目管理示例,请参阅

const cosmos = require('@azure/cosmos');
const endpoint = process.env.COSMOS_ENDPOINT; // Use the name of the setting that contains your Endpoint
const key = process.env.COSMOS_KEY; // Use the name of the setting that contains your Key
const { CosmosClient } = cosmos;

const client = new CosmosClient({ endpoint, key });
// All function invocations also reference the same database and container.
// If on the contrary you need to change the container based on the Trigger, then create the instance inside the Function
const container = client.database("YourDatabase").container("YourContainer");

module.exports = async function (context) {
    const item = container.item("id to delete", "partition key value for item");
    await item.delete();
}