here's my scenario.
- I have a legacy time-trigger based Job processing system. I would like to migrate them to AzureFunction/ WebJob.
- There is a finite set of C# methods.
- These C# methods would be configured dynamically/during runtime in another database so that there would be multiple time-triggers calling the same C# method with different parameter.
- Note that, there is a one-many relation between C# method and the configuration of TimeTrigger & input parameters.
- Some of Job logic requires a heavy in-memory/stateful initialization, for e.g., during static/common initialization, all of the jobs need to share a 1GB in-memory cache. We cannot do this load everytime Job starts. It is due to this specification, that I mentioned WebJob, instead of AzureFunctions, which is more suitable for stateless and faster operations.
now, my problem,
I see that in AzureFunction/WebJob, I have to embed TimeTrigger logic within C# code. This can only be done statically.
For instance,
[Singleton]
public void Run_Code1_withTrigger1([TimerTrigger("0 */1 * * * *", UseMonitor = false)] TimerInfo myTimer, ILogger log, string paramX)
{
// call code1 with paramX=value1
}
[Singleton]
// not time-trigger value is different.
public void Run_Code1_withTrigger2([TimerTrigger("0 */30 * * * *", UseMonitor = false)] TimerInfo myTimer, ILogger log, string paramX)
{
// call code1 with paramX=value2
}
Issue is, to add a new trigger at runtime - Run_Code1_withTrigger3, that has different schedule and different parameters, but with exact same Code1, a simple update in DB was sufficient in our legacy app. It may require a full redeployment of WebJobs/ AzureFunctions (unless I'm wrong).
I would like to have Trigger configured via configuration (not code) and decoupled with code (invocation).
I looked into extensibility features for e.g. IWebJobsBuilder.AddExtension/ BindOptions, but unable to find the right extension yet for runtime management.
I simply need the ability to...
- Question: Create new TimeTrigger job that calls existing Code1 (at runtime without restarting service).
- Disable existing job (it appears this could be achieved via link)
- Question: Modification of existing TimeTrigger. I want to change the frequency from 30s to say 50s for a running job.
How may I achieve this in WebJob? Is there a way to achieve the same in AzureFunctions?