Azure Cosmos数据库功能 - 删除文档

问题描述:

我可以在Azure上使用HTTP trigger in FunctionsApp使用HTTP trigger in FunctionsApp获得文档响应,就像rest API一样但是,我无法删除文档。Azure Cosmos数据库功能 - 删除文档

我选择DELETE作为选中的'HTTP methods'但我不清楚下一步该怎么做。 在输入参数中,当我在SQL Query (optional) textbox中编写'Delete from mydocument'时,它不起作用。 也许我需要更改'run.csx'代码,但是如何?

任何线索?

enter image description hereenter image description hereenter image description here

+0

的https://stackoverflow.com/questions/46505301/delete-document-in-cosmosdb-through-azure-function – Mikhail

相信“SQL查询”部分是输入的“发现”,你想用的文件结合。这取决于你想如何继续,这仍然可能是有用的。如果需要,您仍然可以使用HTTP Delete触发器,但只是“说”其DELETE谓词不会自动执行删除操作。相反,这意味着只有在将其指定为DELETE操作时才能“调用”函数。

我以前通过直接绑定到DocumentClient本身删除了文档,并以编程方式删除了Document。

[FunctionName("DeleteDocument")] 
    public static async Task Run(
     [TimerTrigger("00:01", RunOnStartup = true)] TimerInfo timer, 
     [DocumentDB] DocumentClient client, 
     TraceWriter log) 
    { 
     var collectionUri = UriFactory.CreateDocumentCollectionUri("ItemDb", "ItemCollection"); 
     var documents = client.CreateDocumentQuery(collectionUri); 

     foreach (Document d in documents) 
     { 
      await client.DeleteDocumentAsync(d.SelfLink); 
     } 
    } 

DocumentDBSamples

+0

重复谢谢您的回答。我今天要看看你的方法。 – MareCieco

+0

这不适用于分区集合。 –