azure - 预定的网络作业与时间表混淆

标签 azure azure-webjobs azure-webjobssdk

我有一个网络作业需要每天凌晨 1 点运行。 我的settings.job配置如下:

{
    "schedule": "0 0 1 * * *",
    "is_singleton":  true 
}

我在 Functions.cs 中声明了函数

   namespace Dsc.Dmp.SddUpgrade.WebJob
{
    using System;
    using System.IO;

    using Microsoft.Azure.WebJobs;

    public class Functions
    {
        public static void TriggerProcess(TextWriter log)
        {
            log.Write($"C# Timer trigger function executed at: {DateTime.Now}");
        }
    }
}

我收到以下日志:

[09/28/2017 12:02:05 > 9957a4: SYS INFO] Status changed to Running
[09/28/2017 12:02:07 > 9957a4: INFO] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

当我阅读文档时,有些人正在使用这样的函数签名:

public static void TriggerProcess([TimerTrigger("0 0 1 * * *")] TimerInfo timerInfo, TextWriter log)

但是,这对我来说似乎不合逻辑,因为已经在 settings.job 中配置了我的网络作业。

我在这里缺少什么?

最佳答案

如果您使用 settings.job 文件来安排您的 WebJob,您的逻辑应该位于 Program.cs 的 Main 函数中。如果您选择此路线,则可以忽略 Functions.cs 文件。这对于将控制台应用程序迁移到 WebJob 并对其进行调度非常有用。

TimerTrigger 是一个 WebJob 扩展。它很有用,因为 Functions.cs 中可以有多个方法,每个方法都有一个按不同计划执行的单独的 TimerTrigger。要使用这些,您的 WebJob 需要连续。

关于azure - 预定的网络作业与时间表混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46468918/

相关文章:

azure - 当 Azure WebJobs SDK 仪表板连接字符串根本不为空时,为什么我会收到异常“Azure WebJobs SDK 仪表板连接字符串缺失或为空”?

azure - 如何在没有 "Always On"的情况下保持 Azure WebJob 运行

caching - Azure 缓存不起作用(错误代码<ERRCA0017> :SubStatus<ES0006>). SDK 2.2

c# - 无法使用 MySql + MVC4 找到或加载已注册的 .Net Framework 数据提供程序

Azure Functions 筛选器功能正式发布

azure - 添加-AzureRmVhd : Resource group 'ResourceGroupName' could not be found

azure-functions - 从 azure 函数推迟或放弃消息服务总线队列

c# - 如何将我的控制台应用程序 dll 放入逻辑应用程序调度程序而不是 Web 作业中?

azure-webjobs - 如何在运行时设置Azure WebJob队列名称?

azure - Microsoft.WindowsAzure.Storage.StorageException : 'The remote server returned an error: (400) Bad Request