【发布时间】:2019-02-04 22:29:27
【问题描述】:
程序.cs:
public static void Main(string[] args)
{
var builder = new HostBuilder()
.ConfigureLogging((context, b) =>
{
b.SetMinimumLevel(LogLevel.Debug);
b.AddConsole();
})
.UseConsoleLifetime();
var host = builder.Build();
using (host)
{
host.Run();
}
}
函数.cs:
public class Functions
{
private readonly ISampleServiceA _sampleServiceA;
private readonly ISampleServiceB _sampleServiceB;
public Functions(ISampleServiceA sampleServiceA, ISampleServiceB sampleServiceB)
{
_sampleServiceA = sampleServiceA;
_sampleServiceB = sampleServiceB;
}
public static void RunSomething([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, ILogger log) // every one minute
{
if (myTimer.IsPastDue)
{
log.LogInformation("Timer is running late!");
}
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
当我跑步时,我得到:
dbug: Microsoft.Extensions.Hosting.Internal.Host[1]
Hosting starting
dbug: Microsoft.Extensions.Hosting.Internal.Host[2]
Hosting started
我已经阅读了几个示例,并认为通过创建新的控制台应用程序、引用所需的程序集以及包括上述内容,WebJob 应该“正常工作”。我是否遗漏了一些关键配置?
版本:
【问题讨论】:
-
你的问题解决了吗?
标签: c# .net azure azure-webjobs