Functions.Templates/Templates/CosmosDBTrigger-CSharp-3.x/CosmosDBTriggerCSharp.cs (26 lines of code) (raw):
using System;
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
{
// This template uses an outdated version of the Azure Cosmos DB extension. Learn about migrating to the new extension at https://aka.ms/migrate-to-cosmos-extension-v4
[FunctionName("CosmosDBTriggerCSharp")]
public static void Run([CosmosDBTrigger(
databaseName: "DatabaseValue",
collectionName: "CollectionValue",
ConnectionStringSetting = "ConnectionValue",
LeaseCollectionName = "leases")]IReadOnlyList<Document> input,
ILogger log)
{
if (input != null && input.Count > 0)
{
log.LogInformation("Documents modified " + input.Count);
log.LogInformation("First document Id " + input[0].Id);
}
}
}
}