Cosmos.ChangeStream.TriggerBinding
1.0.0-beta
dotnet add package Cosmos.ChangeStream.TriggerBinding --version 1.0.0-beta
NuGet\Install-Package Cosmos.ChangeStream.TriggerBinding -Version 1.0.0-beta
<PackageReference Include="Cosmos.ChangeStream.TriggerBinding" Version="1.0.0-beta" />
paket add Cosmos.ChangeStream.TriggerBinding --version 1.0.0-beta
#r "nuget: Cosmos.ChangeStream.TriggerBinding, 1.0.0-beta"
// Install Cosmos.ChangeStream.TriggerBinding as a Cake Addin
#addin nuget:?package=Cosmos.ChangeStream.TriggerBinding&version=1.0.0-beta&prerelease
// Install Cosmos.ChangeStream.TriggerBinding as a Cake Tool
#tool nuget:?package=Cosmos.ChangeStream.TriggerBinding&version=1.0.0-beta&prerelease
CosmosChangeStreamTriggerBinding
Azure Function trigger binding that listens to Azure Cosmos DB API for MongoDB's change stream API and triggers an execution on insert, update or replace events. (Requires Azure Cosmos DB's API for MongoDB ver. 3.6+)
Releases
Azure Cosmos DB MongoDB API change stream trigger binding for Azure Functions is released as a NuGet package.
- Download the NuGet package.
- See Release notes.
Usage
The workflow
- Install package using Install-Package Cosmos.ChangeStream.TriggerBinding -Version 1.0.0-beta
- Set environment variables and specify their keys in the trigger attribute, i.e. CosmosDBConnectionString and CosmosDBDatabase.
Example
using CosmosChangeStreamTriggerBinding;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Threading.Tasks;
namespace CosmosDbMongoDbAPITriggeredFunctionApp
{
public static class ProcessDocument
{
public static async Task RunAsync(
[CosmosDbCustomTrigger(
Connection = "CosmosDBConnectionString",
DatabaseName = "CosmosDBDatabase",
CollectionName = "CosmosDBCollection")] string document,
ILogger log)
{
try
{
var docObject = JsonConvert.DeserializeObject<CosmosChangeStreamTriggerBinding.Model.Document>(document);
}
catch (Exception ex)
{
log.LogCritical(ex.Message + Environment.NewLine + "Stack trace was:" + Environment.NewLine + ex.StackTrace.ToString() +
Environment.NewLine + Environment.NewLine + "Inner exception was:" + Environment.NewLine + ex.InnerException.ToString());
throw new Exception(ex.Message, ex);
}
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
- Microsoft.Azure.WebJobs (>= 3.0.27)
- MongoDB.Driver (>= 2.12.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0-beta | 214 | 4/26/2021 |
- First publicly available beta release of Azure Function trigger binding for Azure Cosmos DB API for MongoDB.
- Implements https://docs.microsoft.com/en-us/azure/cosmos-db/mongodb-change-streams?tabs=csharp#examples as a custom Azure Function trigger binding for ease of use.
- Takes connection string, collection name and database name as environment variables in the trigger attribute.
- Targets .NET Standard 2.1, which supports .NET Core 3.0+ and .NET 5+.