Calling a job manually

If you would like to trigger a job manually, you can use the [NoAutomaticTrigger] attribute to tell a host that this particular function is not triggered automatically. Here, you have an example of the one I created and named Manual.cs:

using System.IO;using Microsoft.Azure.WebJobs;namespace MyFirstWebJobWebJobsSDK{    public class Manual    {        [NoAutomaticTrigger]        public static void ManualFunction(            TextWriter logger,            string value)        {            logger.WriteLine($"Received message: {value}");        }    }}

Now let's see what happens if you call it from the main point of your program:

using Microsoft.Azure.WebJobs;namespace MyFirstWebJobWebJobsSDK{    class Program    {        static void Main()        {            var config = new JobHostConfiguration(); var host = new JobHost(config); ...

Get Hands-On Azure for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.