Cosmos.ChangeStream.TriggerBinding 1.0.0-beta

This is a prerelease version of Cosmos.ChangeStream.TriggerBinding.
dotnet add package Cosmos.ChangeStream.TriggerBinding --version 1.0.0-beta
NuGet\Install-Package Cosmos.ChangeStream.TriggerBinding -Version 1.0.0-beta
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cosmos.ChangeStream.TriggerBinding" Version="1.0.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cosmos.ChangeStream.TriggerBinding --version 1.0.0-beta
#r "nuget: Cosmos.ChangeStream.TriggerBinding, 1.0.0-beta"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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+.