Azure / azure-webjobs-sdk-extensions

Azure WebJobs SDK Extensions
MIT License
344 stars 206 forks source link

CosmosDBTriggerAttribute needs to support wildcard for databasenames #634

Open jbt00000 opened 4 years ago

jbt00000 commented 4 years ago

CosmosDBTriggerAttribute needs to support wildcards/regex/lists for databasename.

Use case is when when you have a multi-tenanted system you want to use the same trigger and same function.

Right now, each time I create a new tenant, I'm forced to recompile and redeploy my function, adding in a new attribute. This crushes my workflow.

jbt00000 commented 4 years ago

As you have parameter replacement.... what's needed are the following:

  1. The CosmosDBTriggerAttribute needs allowmultiple. Right now, you can only specify this once. During a visual studio compile and zip deploy, the compiler takes this information and creates the function.json files that defines the triggers for each function. Based on the JSON, it seems that multiple triggers are allowed. But it is hard to replace the function.json file, especially in a zip deploy. So... we need multiple triggers. This would allow me as a HACK to create 100 in advance, each assigned to a different placeholder template parameter that one could change from the azure portal at runtime.

  2. RegularExpressions! If for database name, I could pass in a pattern [CosmosDBTrigger(databaseName:"DatabaseForTenant\d+" ...] that would rid us of all types of hacks.