致命错误 - Azure 存储队列与 Service Fabric

Fatal Error - Azure Storage Queues with Service Fabric

我一直在尝试为 Service Fabric 内的 Azure 存储队列上发布的消息添加侦听器。我在无状态服务中使用的代码片段如下:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Fabric;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
using Microsoft.WindowsAzure.Storage.Queue;
using Notification;

namespace My.Notification
{
    /// <summary>
    /// An instance of this class is created for each service instance by the Service Fabric runtime.
    /// </summary>'
    internal sealed class Notification : StatelessService
    {
        public Notification(StatelessServiceContext context)
            : base(context)
        {




        }

        /// <summary>
        /// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests.
        /// </summary>
        /// <returns>A collection of listeners.</returns>
        protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
        {
            return new ServiceInstanceListener[0];
        }

        //First option
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            JobHostConfiguration config = new JobHostConfiguration();
            config.DashboardConnectionString = "string";
            config.StorageConnectionString = "stringg";
            config.Queues.BatchSize = 10;
            config.Queues.MaxDequeueCount = 8;
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(30);
            var host = new JobHost(config);

            //Breaks below
            await host.CallAsync(typeof(Notification).GetMethod("ProcessMethod"), cancellationToken);
            host.RunAndBlock();

        }

        //Second option
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            try
            {
                var config = new JobHostConfiguration
                {
                    DashboardConnectionString = "string",//Real connection string,
                    StorageConnectionString = "string",
                    Queues =
                    {
                        BatchSize = 1,
                        MaxDequeueCount = 3,
                        MaxPollingInterval = TimeSpan.FromSeconds(30)
                    }
                };
                var host = new JobHost(config);

                //Breaks here
                await host.StartAsync(cancellationToken);
            }
            catch (Exception ex)
            {
                //ServiceEventSource.Current.ServiceStartupFailedEvent(ex.ToString());
                throw;
            }
        }

        [NoAutomaticTrigger]
        public static async Task ProcessMethod(CancellationToken cancellationToken)
        {
            long iterations = 0;
            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();
                //log
                Trace.TraceInformation(">>[{0}]ProcessMethod Working-{1}", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"), ++iterations);
                //sleep for 5s
                await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
            }
        }


        //[Timeout("00:03:00")]
        public static void ProcessNotificationsInQueue([QueueTrigger("emailqueue")] string message)
        {
            Trace.TraceInformation(">ProcessNotificationsInQueue invoked with notification:{0}", message);
        }
    }
}

我得到的错误如下所示。我已经尝试了两种方法,但我不确定如何获得除此之外的更多详细信息。一些帖子建议我们启用 MDA,我也试过了。其他人指出这可能是 CLR 问题。我也看过这个 并且我有几乎相同的默认设置。

好的,根据讨论找到解决方案 here 我的 Azure WebJobs 版本依赖于存储。 Storage 的版本是 9.0.0,其中删除了一个方法。 Non-availability 是导致这次崩溃的原因。