Last post May 06, 2019 02:06 AM by Fei Han - MSFT
May 02, 2019 10:55 AM|rakshasolanki|LINK
I have created a function which is triggered by a timer. It runs fine when triggered from the Azure portal by clicking on the Run option on the exact time provided through the database. But does not fire automatically for the scheduled date taken from a
database. The timer schedule here is not static but the value is taken from the database and converted to CRON expression. Used INameResolver to resolve the name and overwrite it with the database date and time by converting it to CRON expression.
It runs fine when a constant CRON expression is passed to TimerTrigger attribute.
Any help on this matter would be appreciated.
Thanks in Advance
May 03, 2019 02:42 AM|Fei Han - MSFT|LINK
Hi Raksha Solanki,
Welcome to ASP.NET forums.
The timer schedule here is not static but the value is taken from the database and converted to CRON expression. Used INameResolver to resolve the name and overwrite it with the database date and time by converting it to CRON expression.
It seems that you'd like to dynamically specify ScheduleExpression in code for your timer trigger Web Job based on the data that you stored in database. As you mentioned, we can do that by passing a NameResolver object in to the JobHostConfiguration object,
for detailed information, please check the following link:
[Custom binding expressions](https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#custom-binding-expressions).
And I did a test to achieve the requirement with following code snippet, which work well for me.
public class ScheduleExpressionResolver : INameResolver
public string Resolve(string name)
//in your code, you can retrieve the data from your database
//then dynamically generate CRON expression
return "*/30 * * * * *";
Pass NameResolver class in to the JobHost object, like below.
static void Main()
var config = new JobHostConfiguration();
config.NameResolver = new ScheduleExpressionResolver();
var host = new JobHost(config);
// The following code ensures that the WebJob will be running continuously
Code of schedule job.
public static void StartJob([TimerTrigger("%custom_corn_expression_name_here%", RunOnStartup = false)]TimerInfo timerInfo)
May 03, 2019 04:28 AM|rakshasolanki|LINK
Thanks for the above piece of code.
Can you please guide me with a solution for deploying this web job on Azure portal so that it gets triggered automatically on the schedule taken from the database as the user can change the settings for date and time from the front end at any time.
I have tried by deploying the web job on Azure portal from the Visual Studio 2017. But it needs to be externally triggered by clicking the run option provided on the portal and does not trigger automatically on the provided schedule taken from the database.
Thanks and Regards,
May 06, 2019 02:06 AM|Fei Han - MSFT|LINK
Hi Raksha Solanki,
I tried to deploy my testing WebJobs to Azure, which do work well as expected. The following is execution logs:
You can refer to this documentation to deploy the WebJobs to Azure App Service.
Besides, if you have further questions about Azure WebJobs, you can also get help on StackOverflow for WebJobs.