首页 文章

Azure cosmos db触发器

提问于
浏览
1

是否可以在azure管道中调用cosmos db trigger?管道只是将数据从azrue存储复制到cosmos db集合,并且必须调用预触发 . 如何为复制活动指定触发器ID?

1 回答

  • 0

    根据您的说法,您可以通过使用带有Blob TriggerDocumentDB 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
          };
    }
    

相关问题