I hope you can help me.
I'm new to Azure and having lots of trouble understanding it. I'm trying to write an azure function, who is triggered with EventHubTrigger (when a new event is sent to eventHub), and will store the event in my table in cosmos db. (cosmos db as an output).
I'm writing in C# so that function.json is created automatically and I can't edit it. I can't seem to make it work, to set the trigger and output binding correctly.
this is my function code:
[FunctionName("InsertEvent")]
public static void Run(
[EventHubTrigger("WaterlyNamespace",
Connection = "connectionStr")] string eventHubString,
[CosmosDB(
databaseName: "waterly_db",
collectionName: "water_table",
Id = "device_id",
ConnectionStringSetting = "conStr" )] out dynamic dbItem,
ILogger log)
{
log.LogInformation("C# trigger function processed an event from eventhub");
EventItem dataJson = JsonConvert.DeserializeObject<EventItem>(eventHubString);
//adding timestamp to event json
dataJson.timestamp = DateTime.Now;
dbItem = dataJson;
}
This is the function.json generated:
{
"generatedBy": "Microsoft.NET.Sdk.Functions-3.0.3",
"configurationSource": "attributes",
"bindings": [
{
"type": "eventHubTrigger",
"connection": "ConnectionStr",
"eventHubName": "WaterlyNamespace",
"name": "eventHubString"
}
],
"disabled": false,
"scriptFile": "../bin/Waterly-iot-functions.dll",
"entryPoint": "Waterly_iot_functions.InsertEvent.Run"
}
This is the host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
},
"extensions": {
"cosmosDB": {
"connectionMode": "Gateway",
"protocol": "Https",
"leaseOptions": {
"leasePrefix": "prefix1"
}
}
}
}
and this is what I see in the Azure portal after publishing this code: See Image
Any ideas why the trigger is in the output area in the Azure portal, and what am I missing?
Any help would be very appreciated. Thanks,