Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c8f5f3a

Browse files
authoredMay 16, 2022
Merge pull request #191936 from ggailey777/kafka
Kafka bindings
2 parents cad78e8 + c4690ff commit c8f5f3a

8 files changed

+1038
-4
lines changed
 

‎.openpublishing.publish.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@
242242
"branch": "main",
243243
"branch_mapping": {}
244244
},
245+
{
246+
"path_to_root": "azure-functions-kafka-extension",
247+
"url": "https://github.com/Azure/azure-functions-kafka-extension",
248+
"branch": "dev",
249+
"branch_mapping": {}
250+
},
245251
{
246252
"path_to_root": "azure-functions-python-worker-extension",
247253
"url": "https://github.com/Azure-Samples/python-worker-extension-timer",

‎articles/azure-functions/TOC.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,16 @@
634634
href: functions-bindings-event-iot-trigger.md
635635
displayName: Azure IoT Hubs
636636
- name: Kafka
637-
href: https://github.com/azure/azure-functions-kafka-extension
637+
items:
638+
- name: Overview
639+
href: functions-bindings-kafka.md
640+
displayName: Kafka
641+
- name: Trigger
642+
href: functions-bindings-kafka-trigger.md
643+
displayName: Kafka
644+
- name: Output
645+
href: functions-bindings-kafka-output.md
646+
displayName: Kafka
638647
- name: HTTP and webhooks
639648
items:
640649
- name: Overview

‎articles/azure-functions/functions-bindings-kafka-output.md

Lines changed: 379 additions & 0 deletions
Large diffs are not rendered by default.

‎articles/azure-functions/functions-bindings-kafka-trigger.md

Lines changed: 470 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
title: Apache Kafka bindings for Azure Functions
3+
description: Learn to integrate Azure Functions with an Apache Kafka stream.
4+
author: ggailey777
5+
ms.topic: reference
6+
ms.date: 05/14/2022
7+
ms.author: glenga
8+
zone_pivot_groups: programming-languages-set-functions-lang-workers
9+
---
10+
11+
# Apache Kafka bindings for Azure Functions overview
12+
13+
The Kafka extension for Azure Functions lets you write values out to [Apache Kafka](https://kafka.apache.org/) topics by using an output binding. You can also use a trigger to invoke your functions in response to messages in Kafka topics.
14+
15+
> [!IMPORTANT]
16+
> Kafka bindings are only available for Functions on the [Elastic Premium Plan](functions-premium-plan.md) and [Dedicated (App Service) plan](dedicated-plan.md). They are only supported on version 3.x and later version of the Functions runtime.
17+
18+
| Action | Type |
19+
|---------|---------|
20+
| Run a function based on a new Kafka event. | [Trigger](./functions-bindings-kafka-trigger.md) |
21+
| Write to the Kafka event stream. |[Output binding](./functions-bindings-kafka-output.md) |
22+
23+
::: zone pivot="programming-language-csharp"
24+
25+
## Install extension
26+
27+
The extension NuGet package you install depends on the C# mode you're using in your function app:
28+
29+
# [In-process](#tab/in-process)
30+
31+
Functions execute in the same process as the Functions host. To learn more, see [Develop C# class library functions using Azure Functions](functions-dotnet-class-library.md).
32+
33+
Add the extension to your project by installing this [NuGet package](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Kafka).
34+
35+
# [Isolated process](#tab/isolated-process)
36+
37+
Functions execute in an isolated C# worker process. To learn more, see [Guide for running C# Azure Functions in an isolated process](dotnet-isolated-process-guide.md).
38+
39+
Add the extension to your project by installing this [NuGet package](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Kafka).
40+
41+
<!--
42+
# [C# script](#tab/csharp-script)
43+
44+
Functions run as C# script, which is supported primarily for C# portal editing. To update existing binding extensions for C# script apps running in the portal without having to republish your function app, see [Update your extensions].
45+
46+
The Kafka extension is part of an [extension bundle], which is specified in your host.json project file. When you create a project that targets version 2.x or later, you should already have this bundle installed. To learn more, see [extension bundle].
47+
-->
48+
49+
---
50+
51+
::: zone-end
52+
53+
::: zone pivot="programming-language-javascript,programming-language-python,programming-language-java,programming-language-powershell"
54+
55+
## Install bundle
56+
57+
The Kafka extension is part of an [extension bundle], which is specified in your host.json project file. When you create a project that targets Functions version 3.x or later, you should already have this bundle installed. To learn more, see [extension bundle].
58+
59+
::: zone-end
60+
61+
## Enable runtime scaling
62+
63+
To allow your functions to scale properly on the Premium plan when using Kafka triggers and bindings, you need to enable runtime scale monitoring.
64+
65+
# [Azure portal](#tab/portal)
66+
67+
In the Azure portal, in your function app, choose **Configuration** and on the **Function runtime settings** tab turn **Runtime scale monitoring** to **On**.
68+
69+
:::image type="content" source="media/functions-create-vnet/11-enable-runtime-scaling.png" alt-text="Enable runtime scaling in the Azure portal.":::
70+
71+
# [Azure CLI](#tab/azure-cli)
72+
73+
Use the following Azure CLI command to enable runtime scale monitoring:
74+
75+
```azurecli-interactive
76+
az resource update -g <RESOURCE_GROUP> -n <FUNCTION_APP_NAME>/config/web --set properties.functionsRuntimeScaleMonitoringEnabled=1 --resource-type Microsoft.Web/sites
77+
```
78+
79+
---
80+
81+
## host.json settings
82+
83+
This section describes the configuration settings available for this binding in versions 3.x and higher. Settings in the host.json file apply to all functions in a function app instance. For more information about function app configuration settings in versions 3.x and later versions, see the [host.json reference for Azure Functions](functions-host-json.md).
84+
85+
```json
86+
{
87+
"version": "2.0",
88+
"extensions": {
89+
"kafka": {
90+
"maxBatchSize": 64,
91+
"SubscriberIntervalInSeconds": 1,
92+
"ExecutorChannelCapacity": 1,
93+
"ChannelFullRetryIntervalInMs": 50
94+
}
95+
}
96+
}
97+
98+
```
99+
100+
|Property |Default | Type | Description |
101+
|---------|---------|---------| ---- |
102+
| ChannelFullRetryIntervalInMs | 50 | Trigger | Defines the subscriber retry interval, in milliseconds, used when attempting to add items to an at-capacity channel. |
103+
| ExecutorChannelCapacity | 1| Both| Defines the channel message capacity. Once capacity is reached, the Kafka subscriber pauses until the function catches up. |
104+
| MaxBatchSize | 64 | Trigger | Maximum batch size when calling a Kafka triggered function. |
105+
| SubscriberIntervalInSeconds | 1 | Trigger | Defines the minimum frequency incoming messages are executed, per function in seconds. Only when the message volume is less than `MaxBatchSize` / `SubscriberIntervalInSeconds`|
106+
107+
The following properties, which are inherited from the [Apache Kafka C/C++ client library](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md), are also supported in the `kafka` section of host.json, for either triggers or both output bindings and triggers:
108+
109+
|Property | Applies to | librdkafka equivalent |
110+
|---------|---------|---------|
111+
| AutoCommitIntervalMs | Trigger | `auto.commit.interval.ms` |
112+
| FetchMaxBytes | Trigger | `fetch.max.bytes` |
113+
| LibkafkaDebug | Both | `debug` |
114+
| MaxPartitionFetchBytes | Trigger | `max.partition.fetch.bytes` |
115+
| MaxPollIntervalMs | Trigger | `max.poll.interval.ms` |
116+
| MetadataMaxAgeMs | Both | `metadata.max.age.ms` |
117+
| QueuedMinMessages | Trigger | `queued.min.messages` |
118+
| QueuedMaxMessagesKbytes | Trigger | `queued.max.messages.kbytes` |
119+
| ReconnectBackoffMs | Trigger | `reconnect.backoff.max.ms` |
120+
| ReconnectBackoffMaxMs | Trigger | `reconnect.backoff.max.ms` |
121+
| SessionTimeoutMs | Trigger | `session.timeout.ms` |
122+
| SocketKeepaliveEnable | Both | `socket.keepalive.enable` |
123+
| StatisticsIntervalMs | Trigger | `statistics.interval.ms` |
124+
125+
126+
## Next steps
127+
128+
- [Run a function from an Apache Kafka event stream](./functions-bindings-kafka-trigger.md)
129+
130+
[extension bundle]: ./functions-bindings-register.md#extension-bundles

‎articles/azure-functions/functions-bindings-storage-table-input.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ The usage of the binding depends on the extension package version and the C# mod
2222

2323
# [In-process](#tab/in-process)
2424

25-
An in-process class library is a compiled C# function runs in the same process as the Functions runtime.
25+
An [in-process class library](functions-dotnet-class-library.md) is a compiled C# function runs in the same process as the Functions runtime.
2626

2727
# [Isolated process](#tab/isolated-process)
2828

29-
An isolated process class library compiled C# function runs in a process isolated from the runtime. Isolated process is required to support C# functions running on .NET 5.0.
29+
An [isolated process class library](dotnet-isolated-process-guide.md) compiled C# function runs in a process isolated from the runtime. Isolated process is required to support C# functions running on .NET 5.0.
3030

3131
# [C# script](#tab/csharp-script)
3232

‎includes/functions-bindings-csharp-intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.date: 11/16/2021
66
ms.author: glenga
77
---
88

9-
The C# function can be created using one of the following C# modes:
9+
A C# function can be created using one of the following C# modes:
1010

1111
* [In-process class library](../articles/azure-functions/functions-dotnet-class-library.md): compiled C# function that runs in the same process as the Functions runtime.
1212
* [Isolated process class library](../articles/azure-functions/dotnet-isolated-process-guide.md): compiled C# function that runs in a process isolated from the runtime. Isolated process is required to support C# functions running on .NET 5.0.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
author: ggailey777
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 05/14/2022
6+
ms.author: glenga
7+
---
8+
9+
## Connections
10+
11+
All connection information required by your triggers and bindings should be maintained in application settings and not in the binding definitions in your code. This is true for credentials, which should never be stored in your code.
12+
13+
> [!IMPORTANT]
14+
> Credential settings must reference an [application setting](../articles/azure-functions/functions-how-to-use-azure-function-app-settings.md#settings). Don't hard-code credentials in your code or configuration files. When running locally, use the [local.settings.json file](../articles/azure-functions/functions-develop-local.md#local-settings-file) for your credentials, and don't publish the local.settings.json file.
15+
16+
# [Confluent](#tab/confluent)
17+
18+
When connecting to a managed Kafka cluster provided by [Confluent in Azure](https://www.confluent.io/azure/), make sure that the following authentication credentials for your Confluent Cloud environment are set in your trigger or binding:
19+
20+
| Setting | Recommended value | Description |
21+
| --- | --- | --- |
22+
| **BrokerList** | `BootstrapServer` | App setting named `BootstrapServer` contains the value of bootstrap server found in Confluent Cloud settings page. The value resembles `xyz-xyzxzy.westeurope.azure.confluent.cloud:9092`. |
23+
| **Username** | `ConfluentCloudUsername` | App setting named `ConfluentCloudUsername` contains the API access key from the Confluent Cloud web site. |
24+
| **Password** | `ConfluentCloudPassword` | App setting named `ConfluentCloudPassword` contains the API secret obtained from the Confluent Cloud web site. |
25+
26+
# [Event Hubs](#tab/event-hubs)
27+
28+
When connecting to Event Hubs, make sure that the following authentication credentials for your Event Hubs instance are set in your trigger or binding:
29+
30+
| Setting | Recommended value | Description |
31+
| --- | --- | --- |
32+
| **BrokerList** | `BootstrapServer` | App setting named `BootstrapServer` contains the fully qualified domain name of your Event Hubs instance. The value resembles `<MY_NAMESPACE_NAME>.servicebus.windows.net:9093`. |
33+
| **Username** | `$ConnectionString` | Actual value is obtained from the connection string. |
34+
| **Password** | `%EventHubsConnectionString%` | App setting named `EventHubsConnectionString` contains the connection string for your Event Hubs namespace. To learn more, see [Get an Event Hubs connection string](../articles/event-hubs/event-hubs-get-connection-string.md).|
35+
36+
---
37+
38+
The string values you use for these settings must be present as [application settings in Azure](../articles/azure-functions/functions-how-to-use-azure-function-app-settings.md#settings) or in the `Values` collection in the [local.settings.json file](../articles/azure-functions/functions-develop-local.md#local-settings-file) during local development.
39+
40+
You should also set the `Protocol`, `AuthenticationMode`, and `SslCaLocation` in your binding definitions.

0 commit comments

Comments
 (0)
Please sign in to comment.