2

I've read many posts re how to use Imperative input and output bindings - I get that, very cool.

However, what I have struggled to find is a way to create Imperative Triggers. I'm not sure if this is possible at this point.

What I would like to do:

  • In my Startup.cs which implements IWebJobsStartup create an EventHubTrigger for an Azure function at runtime so that I can specify the ConsumerGroup property dynamically, allowing me to use a specific ConsumerGroup when running in an Azure Deployment Slot vs the ConsumerGroup being used in the live slot. I don't want them competing for events, my zero downtime deployment strategy depends on this.
  • Or a similar approach...

What I am doing:

  • In my Azure DevOps release process ensuring that I have a sticky slot app setting and setting that to a distinct value for slot vs live in the respective slots.
  • In my trigger attribute appending the slot setting to the configuration value being used for the ConsumerGroup, which looks like this:
[EventHubTrigger("my-rapids-event-hub", Connection = "EventHub.ConnectionString", 
  ConsumerGroup = "%EventHub.ConsumerGroup%-%SlotConfigExtension%")] EventData[] events,
  [EventHub("my-river-eventhub", Connection = "EventHub.ConnectionString")] IAsyncCollector<string> outputEvents, 
  ILogger log)

The latter approach works, as it successfully concatenates the ConsumerGroup config values:

%EventHub.ConsumerGroup%-%SlotConfigExtension%

It feels a bit less than optimal, though, and I'd prefer to determine how to accomplish the first approach so I can ditch the extra Azure Powershell step in my release process.

Thanks in advance!

Jim Speaker
  • 1,303
  • 10
  • 28
  • did you ever find out more? – Modern Ronin Aug 06 '20 at 14:30
  • No. This is not possible at this time. – Jim Speaker Aug 07 '20 at 15:43
  • 1
    [EventHubTrigger("va-data-connectors", Connection = "EventHub.ConnectionString", ConsumerGroup = "%EventHub.ConsumerGroup.Entity%-%WEBSITE_SLOT_NAME%")] EventData[] events, Binder binder, ILogger log) ----------------------- %WEBSITE_SLOT_NAME% is an environment variable that is available to you on Apps (web, api, function) running on Azure. ------------- When running locally just be sure to have this variable with a value in your local.settings.config. HTH – Jim Speaker Aug 07 '20 at 16:07
  • 1
    Using the above environment variable I was able to eliminate the need for a sticky slot setting and eliminate the powershell that created it from my release process(es). – Jim Speaker Aug 07 '20 at 16:10
  • in my context, I'd need something more dynamic than just an environment variable - thank you for answering, anyway :-) – Modern Ronin Aug 11 '20 at 16:01

0 Answers0