-
Notifications
You must be signed in to change notification settings - Fork 35
/
ConsumeMessageFromKafka.cs
32 lines (28 loc) · 1.33 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
31
32
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
namespace dotnet_isolated_azurefunction
{
using System.Text.Json;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Extensions.Dapr;
using Microsoft.Extensions.Logging;
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
[Function("ConsumeMessageFromKafka")]
public static void Run(
// Note: the value of BindingName must match the binding name in components/kafka-bindings.yaml
[DaprBindingTrigger(BindingName = "%KafkaBindingName%")] JsonElement triggerData,
FunctionContext functionContext)
{
var log = functionContext.GetLogger("ConsumeMessageFromKafka");
log.LogInformation("Hello from Kafka!");
log.LogInformation($"Trigger data: {triggerData}");
}
}
}