-
Notifications
You must be signed in to change notification settings - Fork 35
/
ConsumeMessageFromKafka.cs
30 lines (27 loc) · 1.21 KB
/
ConsumeMessageFromKafka.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
namespace dotnet_azurefunction
{
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Dapr;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
public static class ConsumeMessageFromKafka
{
// The function is triggered by Kafka messages in the Kafka instance referenced by
// the Kafka binding configured under components/kafka-bindings.yaml
// Can be used as an alternative for the node-app in the Dapr Bindings sample
// found at https://github.com/dapr/quickstarts/tree/master/bindings/nodeapp
[FunctionName("ConsumeMessageFromKafka")]
public static void Run(
// Note: the value of BindingName must match the binding name in components/kafka-bindings.yaml
[DaprBindingTrigger(BindingName = "%KafkaBindingName%")] JObject triggerData,
ILogger log)
{
log.LogInformation("Hello from Kafka!");
log.LogInformation($"Trigger data: {triggerData}");
}
}
}