1
votes

I have this very simple webjob

 class Program
{
    static void Main(string[] args)
    {
        JobHostConfiguration config = new JobHostConfiguration
        {
            StorageConnectionString = "mykey",
            DashboardConnectionString = "mykey"
        };

        config.UseTimers();

        JobHost host = new JobHost(config);
        host.RunAndBlock();
    }



    public static void EmailsConsumer([TimerTrigger("00:30:00", RunOnStartup = true)]TimerInfo ti)
    {
        //do something
    }
}

And for some reason it won't work image

Am I doing something wrong or is it a bug?

1

1 Answers

2
votes

According to the exception we could know that we need to set class public. Please have a try to add the public key word then it will work.

public class Program
    {
        static void Main(string[] args)
        {
            JobHostConfiguration config = new JobHostConfiguration
            {
                StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=storageAccountName;AccountKey=xxxxxx",
                DashboardConnectionString = "DefaultEndpointsProtocol=https;AccountName=storageAccountName;AccountKey=xxxx;"
            };

            config.UseTimers();

            JobHost host = new JobHost(config);
            host.RunAndBlock();
        }



        public static void EmailsConsumer([TimerTrigger("00:30:00", RunOnStartup = true)]TimerInfo ti)
        {
            //do something
        }
    }