Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use a .Net TextWriter with Azure WebJobs

I want to do some simple debugging, and Console.Writeline no longer seems to be supported by Azure WebJobs.

I know using a TextWriter class is the answer, and I just inject it into my method. What I don't understand is how I call that method. I cannot invalidate my Main method signature and inject it there.

What am I missing please?

public static void Main(TextWriter log)
{
    //This is is not valid
}
like image 309
Russ Taylor Avatar asked Dec 19 '22 05:12

Russ Taylor


1 Answers

For continous webjob, you can do it like that :

class Program
{
    private static void Main()
    {
        var host = new JobHost();
        host.Call(typeof(Program).GetMethod("Start"));
        host.RunAndBlock();
    }

    [NoAutomaticTrigger]
    public static void Start(TextWriter textWriter)
    {

    }
}
like image 82
Thomas Avatar answered Jan 06 '23 00:01

Thomas