2

We have the following scenario:

  • Our UI is giving the users the option of running their tasks periodically e.g. once in every hour, once in every 12 hours or once a day, etc. The backend that runs the tasks is an Azure timer-triggered function but it spawns periodically based on the configuration defined in the environment variables:
    [Function("JobRunner")]
    public Task RunAsync([TimerTrigger("%RunningCron%")] MyInfo myTimer)
    {
        _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
        _logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus?.Next}");
        //Do something
        return Task.CompletedTask;
    }

The value of "%RunningCron% is constant, and as stated earlier it's coming from environment variables e.g. local.settings.json file, etc.

How can we make the CRON value picked up from the database where the user's choice is stored.

1 Answer 1

0

As per your requirement, We understood that multiple users may access the UI & change their CORN expression accordingly. Using single timer trigger functions won't be the feasible solution here. we would suggest you make the changes to the application UI whenever a user tries to change the CORN expression it should create the Timer trigger function using Rest API based on that particular corn expression.

For example:

If your application is having only one timer trigger function and there were 2 users (user1, user2) who are trying to access your application by passing the dynamic corn expressions.

  • user1 has passed this corn expression as input 0 0 */6 * * * to schedule a particular task (job1) in the application.
  • user2 has passed this CORN expression 0 0 * * * 1-5 to schedule a particular job(job2) in their application.

Since you are using a single timer trigger in your application job1 scheduled by user1 will get overridden by the job2 scheduled by the user2.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply. I was wondering how I can have the function created by the REST API invoke the backend's code? @VenkateshDodda-MSFT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.