我有这个非常简单的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
}
}
由于某种原因,它不会起作用
我做错了什么还是错误?
答案 0 :(得分:2)
根据例外我们可以知道我们需要设置类public。请尝试添加public
关键字然后它将起作用。
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
}
}