How to schedule a WebJob

0 votes

I'm creating a new Azure WebJob project -- which appears to be a polished version of a console app that can run as a web job.

I want this job to run based on a schedule but in the Main() method -- see below -- Microsoft gives you the host.RunAndBlock() for the job to run continuously.

Do I need to change that if I want the job to run at regularly scheduled intervals?

static void Main()
{
    var host = new JobHost();

    // The following code ensures that the WebJob will be running continuously
    host.RunAndBlock();
}
Jun 19, 2018 in Azure by cloudie_crank
• 1,610 points
2,049 views

1 answer to this question.

0 votes

When using the Azure WebJobs SDK you can use TimerTrigger to declare job functions that run on a schedule. For example here's a function that runs immediately on startup, then every two hours thereafter:

public static void StartupJob(
[TimerTrigger("0 0 */2 * * *", RunOnStartup = true)] TimerInfo timerInfo)
{
    Console.WriteLine("Timer job fired!");
}

You can get TimerTrigger and other extensions by installing the Microsoft.Azure.WebJobs.Extensions nuget package. More information on TimerTrigger and the other extensions in that package and how to use them can be found in the azure-webjobs-sdk-extensions repo. When using the TimerTrigger, be sure to add a call to config.UseTimers() to your startup code to register the extension.

When using the Azure WebJobs SDK, you deploy your code to a Continuous WebJob, with AlwaysOn enabled. You can then add however many scheduled functions you desire in that WebJob.

answered Jun 19, 2018 by null_void
• 3,220 points

Related Questions In Azure

0 votes
1 answer

How to Schedule a task in Azure Worker role?

You can simply have a message on ...READ MORE

answered Jul 1, 2019 in Azure by Perry
• 17,100 points
1,107 views
0 votes
1 answer

How can I schedule a pipeline to run in azure datafactory?

You can use the scheduler trigger or ...READ MORE

answered Jan 2, 2020 in Azure by Sirajul
• 59,230 points
650 views
0 votes
1 answer

How to upload a file on to Azure Blob storage without writing a code?

You can find the below tools useful ...READ MORE

answered Apr 13, 2018 in Azure by club_seesharp
• 3,450 points
1,244 views
0 votes
2 answers

How can I download a .vhd image to my local machine from azure and upload the same to a different azure account?

From the Windows Azure Portal you can ...READ MORE

answered Aug 20, 2018 in Azure by Priyaj
• 58,090 points
13,653 views
0 votes
2 answers

How to process a file using Azure Function?

You don't really need a http trigger ...READ MORE

answered Jun 18, 2018 in Azure by club_seesharp
• 3,450 points
6,860 views
0 votes
1 answer

How to identify a deadlock in SQL Azure?

Monitoring of SQL Azure is more limited ...READ MORE

answered Jun 19, 2018 in Azure by club_seesharp
• 3,450 points
2,291 views
0 votes
1 answer

Azure Blob: How to open a file in browser without downloading it?

First, because I was using a byte[] the controller ...READ MORE

answered Jun 20, 2018 in Azure by club_seesharp
• 3,450 points
23,199 views
0 votes
1 answer

How can I copy SQL Azure database to a local development server?

There are certain ways to do this: Using SSIS ...READ MORE

answered Jun 26, 2018 in Azure by null_void
• 3,220 points
967 views
+1 vote
2 answers

How do I establish an connection to Azure IoT Hub? Say a connection like MQTT/AMQP using Python.

Azure IoT Hub comes with 3 SDK's: Service SDK Device ...READ MORE

answered Apr 13, 2018 in Azure by null_void
• 3,220 points
1,909 views
+1 vote
1 answer

How to copy Azure SQL database to a local development server?

Actually, there are multiple ways to do ...READ MORE

answered Jul 9, 2018 in Azure by null_void
• 3,220 points
2,360 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP