We know the Connection string for event hub can be used from local.setting.json file. So for the same function app in different environments, I can add the event hub connection string setting in Application settings in the azure portal.
As the EventHubTrigger function app also expects event name and consumer group(optional) as attributes parameters, I was wondering how the event hub name and consumer group can be used from app settings?
public static void EventHubTriggerFunc([EventHubTrigger("myeventhubname", Connection = "EventHubConnectionAppSetting", ConsumerGroup = "myconsumergroupname")] EventData myEventHubMessage, DateTime enqueuedTimeUtc, Int64 sequenceNumber, string offset, ILogger log)
{
// Here EventHubConnectionAppSetting is specified in local.setting.json file
//myeventhubname & myconsumergroupname are hard coded string
}
local.settings.Json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"EventHubConnectionAppSetting": "Endpoint=.....",
"EventHubConsumerGroup": "myconsumergroup"
}
}