2

I have a Azure Webjob that needs to read from Azure EventHub and write the output to another EventHub.

In all the examples I have seen the name of the Event Hub is specified at compile time directly in the trigger attribute. However, I would like to use different names depending on a value in my config file (so I can name my Event Hub differently in production and testing for example). Is it possible?

Right now my code looks like this, and as you can see the names "xxx" and "yyy" are compile time constants.

public void ProcessQueueMessage(
        [EventHubTrigger("xxx")]EventData[] msgs,
        [EventHub("yyy")]ICollector<EnrichedTrackingEvent> result,
        TraceWriter log)
{
    //...
}
viblo
  • 4,159
  • 4
  • 20
  • 28

1 Answers1

4

Define a Name Resolver and specify it in JobHostConfiguration, as explained in this answer.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • Apparently the default JobHostConfiguration is already setup to pick settings from config, my only change required was to use the %configkey% notation (so no need for my own NameResolver as in the other answer). – viblo Sep 26 '17 at 13:32
  • @viblo, Nice to know, thanks for the update – Mikhail Shilkov Sep 26 '17 at 13:38