Skip to content

Instantly share code, notes, and snippets.

@vainolo
Created November 21, 2018 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vainolo/2c410f5aaee7b3dc14e5e415693e8251 to your computer and use it in GitHub Desktop.
Save vainolo/2c410f5aaee7b3dc14e5e415693e8251 to your computer and use it in GitHub Desktop.
Azure Functions – Part 7: Blob, Queue, and Cosmos DB Triggers - 4
using System.Collections.Generic;
using Microsoft.Azure.Documents;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace Company.Function
{
public static class CosmosDBTriggerCSharp
{
[FunctionName("CosmosDBTriggerCSharp")]
public static void Run(
[CosmosDBTrigger(
databaseName: "mydatabase",
collectionName: "mycollection",
ConnectionStringSetting = "MyCosmosDB")]IReadOnlyList<Document> input,
ILogger log)
{
if (input != null && input.Count > 0)
{
log.LogInformation("Documents modified " + input.Count);
log.LogInformation("First document text " + input[0].GetPropertyValue<string>("text"));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment