简体   繁体   中英

Is it possible to invoke cosmos db trigger from stream analytics?

I have some devices sending data to Azure iot hub. I am using stream analytics service to process the data and insert it in cosmos db documentdb. I thought about use cosmosdb trigger to update some docs when certain items are created, but I found that triggers are invoke via API or SDK. Is it possible to invoke cosmos db trigger from stream analytics? another way to resolve the problem?

There is no trigger in ASA for CosmosDb. But how about using Azure Function Trigger for CosmosDB ? This concept is using CosmosDb Change feed, and it is the easiest way to pick up the changes in your CosmosDb. Below is one example from the documentation attached in the link above.

#r "Microsoft.Azure.DocumentDB.Core"

using System;
using Microsoft.Azure.Documents;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;

public static void Run(IReadOnlyList<Document> documents, ILogger log)
{
  log.LogInformation("Documents modified " + documents.Count);
  log.LogInformation("First document Id " + documents[0].Id);
}

The alternative is to check on CosmosDB change feed manually and implement a solution that occasionaly takes the changes and does whatever you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM