在Queuetrigger中查看错误-Azure WebJobs SDK 3.0



我正在用队列触发器从2.2升级到3.0.4。我添加了存储扩展名nuget软件包,更改了配置代码并使应用程序运行。

它可以从队列中拉出,但是我无法在我的队列触发功能中看到任何错误,也无法在本地击中任何断点。我知道这些消息正在被拾取,因为它是指向我本地存储仿真器的唯一应用程序(带有唯一的队列名称),并且所有消息在添加后几秒钟都直接进入毒药队列。我从未在控制台中看到错误。

我正在使用autoFac,因为2.2实现效果很好 - 我包括autofac.extensions.ipendentencyindoction。

这是我的主题。

static void Main()
    {
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.Write("Initializing DI container...");
        var containerBuilder = new ContainerBuilder();
        RegisterTypes(containerBuilder);
        containerBuilder.RegisterType<BulkUpdateRequestProcessor>();
        containerBuilder.Build();
        Console.Write("done.");
        Console.WriteLine();
        Console.Write("Initializing host configuration...");
        var hostBuilder = new HostBuilder();
        hostBuilder.ConfigureWebJobs(b =>
        {
            b.AddAzureStorageCoreServices()
            .AddAzureStorage(options =>
             {
                 options.BatchSize = 1;
                 options.MaxDequeueCount = 1;
                 options.MaxPollingInterval = TimeSpan.FromSeconds(5f);
             });
            b.AddTimers();
            b.AddExecutionContextBinding();
            b.AddDashboardLogging();

        })
        .ConfigureServices((x) => x.AddAutofac())
        .UseConsoleLifetime();
        Console.Write("done.");
        Console.WriteLine();
        Console.ForegroundColor = ConsoleColor.Green;
        var host = hostBuilder.Build();
        using (host)
        {
            host.Run();
        }
    }

队列处理器:

public class BulkUpdateRequestProcessor
{
    private readonly IRevisionService _revisionService;
    private readonly ILogger _logger;
    private readonly IClock _clock;
    public BulkUpdateRequestProcessor(IRevisionService revisionService, ILogger logger, IClock clock)
    {
        _revisionService = revisionService;
        _logger = logger;
        _clock = clock ?? throw new ArgumentNullException(nameof(clock));
    }
    public async Task ProcessNewJobRequest([QueueTrigger(BulkUpdateConstant.BULK_UPDATE_JOB_QUEUE)] Guid jobId, TextWriter log)
    {
        _logger.Info(string.Format("New item appeared in a queue: '{0}'", jobId));
        try
        {
            await ProcessJobRequest(jobId);
        }
        catch (Exception ex)
        {
            _logger.Log(NLog.LogLevel.Error, ex);
            await TryNotifyJobFailed(jobId, ex.Message);
            throw;
        }
        _logger.Info(string.Format("Request '{0}' processed", jobId));
    }
}

事实证明,包含Web作业绑定的类需要零参数构造函数。我偶然发现了这一点。如果发生构建错误,那将是很好的。-1 Microsoft

相关内容

  • 没有找到相关文章

最新更新