Is it possible to invoke cosmos db trigger in azure pipeline? Pipeline is just copy data from azrue storage to cosmos db collection and it is necessary to invoke pre trigger. How to specify trigger id for copy activity?
1
votes
Are you using Azure Functions? Can you describe what kind of pipeline of events you are using or planning on building? When you say Azure Storage, do you mean Blobs? Queues? Tables?
– Matias Quaranta
@MatiasQuaranta, Speaking about Azure Storage I mean Blobs. My pipeline just copy dataset form blob to cosmos db. And I know how to invoke trigger for example form Node.js documentdb client api. But I should do it in pipeline.
– Pavel Hrynchanka
So if I understand correctly, you want to save data into Cosmos DB when a Blob is uploaded to Azure Storage? And the information you want to store is the content of the Blob or some of its properties?
– Matias Quaranta
Yes, i think it is necessary to write custom activity for this purpose which will implement trigger business logic.
– Pavel Hrynchanka
1 Answers
0
votes
From what you are saying, you might solve this by using Azure Functions with a Blob Trigger and a DocumentDB output binding.
With a functions.json
similar to:
{
"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"
}
]
}
And the function body could be something like:
// 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
};
}