Imperative Triggers in Azure Functions?

202 Views Asked by At

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!

0

There are 0 best solutions below