For more details refer to quickstart: Create your first function in Azure using Visual Studio
This sample will work not only the Windows and Visual Studio. It works on Mac and Linux as well. However, this sample is tested on that enviornment. You can find several way to create a .NET function.
A sample function is provided in folder samples/dotnet/KafkaFunctionSample. It depends on the Kafka installed locally (localhost:9092), as described in previous section. Add a local.settings.json files that looks like this:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "None",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"LocalBroker": "localhost:9092"
}
}
If you have problems connecting to localhost:9092 try to add broker 127.0.0.1
to your host file and use instead of localhost.
You can refer Quick Start on the top page
Restore, Build, and Debug KafkaFunctionSample
.
POST request http://localhost:7071/api/ProduceStringTopic
with JSON Body and ContentType = application/json
.
{"hello":"world"}
Event Hubs provides a Kafka endpoint that can be used by the Kafka extension. For more details, refer to
A sample function is provided in samples/dotnet/KafkaFunctionSample/SimpleKafkaTriggers.cs. Follow the direction of Quickstart: Create an event hub using Azure portal Add a local.settings.json files that looks like this:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "None",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"LocalBroker": "YOUR_EVENTHUBS_NAMESPACE.servicebus.windows.net:9093",
"EHTOPIC": "YOUR_EVENT_HUB_NAME",
"EventHubConnectionString": "YOUR_EVENTHUBS_CONNECTION_STRING"
}
}
For more configuration details for EventHubs, refer to the Use Azure Event Hubs from Apache Kafka applications: Shared Access Signature (SAS)
Restore, Build, and Debug KafkaFunctionSample
.
POST request http://localhost:7071/api/SampleProducer
with raw Body like following.
hello