是否可以指定DocumentDB在寫入DocumentDB時觸發觸發器?Azure函數和DocumentDB觸發器
我有拉JSON消息掀起了服務總線隊列,並將它們放入DocumentDB像這樣的Azure的功能:
using System;
using System.Threading.Tasks;
public static string Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
return myQueueItem;
}
這將插入新文檔到數據庫中,他們將被添加到服務總線隊列,但是我需要DocumentDB在添加和添加附件時處理這些內容。這不能在目前的設置中完成,我想告訴DocumentDB觸發一個觸發器。
我已經試過這樣的事情:
using System;
using System.Threading.Tasks;
public static string Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
return "x-ms-documentdb-post-trigger-include: addDocument\n" + myQueueItem;
}
它不工作,給了我這樣的錯誤:
異常而執行的函數: Functions.ServiceBusQueueTriggerCSharp1。 Microsoft.Azure.WebJobs.Host: 函數返回後處理參數_return時出錯:。 Newtonsoft.Json:解析值時遇到意外的字符: x。路徑',線0,位置0
我喜歡這種設置,因爲我可以請求飽和隊列中添加記錄,他們只是緩衝,直到該數據庫可以處理它,這與在需求高峯的交易,但它允許客戶機上的數據卸載速度與網絡可以承載的速度一樣快,然後當需求再次下降時,隊列/數據庫組合就會被抓住。