是否可以在azure管道中调用cosmos db trigger?管道只是将数据从azrue存储复制到cosmos db集合,并且必须调用预触发。如何为复制活动指定触发器ID?
答案 0 :(得分:0)
根据您的说法,您可以使用带有Blob Trigger和DocumentDB output binding的Azure功能来解决此问题。
functions.json
类似于:
{
"disabled": false,
"bindings": [
{
"name": "myBlob",
"type": "blobTrigger",
"direction": "in",
"path": "<name-of-the-folder-where-files-get-uploaded>",
"connection":"MyStorageAccount"
},
{
"name": "documentToSave",
"type": "documentDB",
"databaseName": "MyDatabase",
"collectionName": "MyCollection",
"createIfNotExists": true,
"connection": "MyAccount_COSMOSDB",
"direction": "out"
}
]
}
功能体可能是这样的:
// Blob trigger binding to a CloudBlockBlob
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Blob;
public static void Run(CloudBlockBlob myBlob, out object documentToSave, TraceWriter log)
{
// some logic to read the blob and parse it
documentToSave = new {
id = "some value",
.. other properties here
};
}