Reputation: 4074
I downloaded some azure webjob examples and got confused. What I want is fairly easy: Given a specific time (once a day) controlled by Cron syntax, I would like to call a method to do some heavy staff.
From the example I downloaded, there is always a Main program:
static void Main(string[] args)
{
JobHost host = new JobHost();
host.RunAndBlock();
}
Then you can define a trigger (e.g. a QueueTrigger)
public static void GenerateThumbnail(
[QueueTrigger("thumbnailrequest")] BlobInformation blobInfo,
[Blob("images/{BlobName}", FileAccess.Read)] Stream input,
[Blob("images/{BlobNameWithoutExtension}_thumbnail.jpg")] CloudBlockBlob outputBlob)
{
}
However, I don't need a queue item to trigger something, all I need is that when my Cron time is matched, My method (say it is Functions.DoThis()) will be fired.
Unfortunately I just couldn't find a way to do it. Can someone help?
Upvotes: 2
Views: 242
Reputation: 43183
You can do this using a Timer Trigger, e.g.
// Runs once every 5 minutes
public static void CronJob([TimerTrigger("0 */5 * * * *")] TimerInfo timer)
{
Console.WriteLine("Cron job fired!");
}
See this page for more info.
Upvotes: 3