Azure存储队列/函数,仅从毒药队列中退出一次

Azure存储队列/函数,仅从毒药队列中退出一次,azure,azure-storage,azure-functions,azure-storage-queues,Azure,Azure Storage,Azure Functions,Azure Storage Queues,我对azure存储功能+azure存储队列有问题。 我有一个队列——“myQueue”和队列触发的azure函数“func1”。在host.json中,我配置了maxDequeueCount(5)和visibilityTimeout——一切都很好 5次尝试后,我的消息转到“myQueue poison”。 我有第二个azure函数“func2”(从func1复制粘贴),它是由“myQueue毒药”触发的队列。我还为此函数在host.json中设置了maxDequeueCount和visibili

我对azure存储功能+azure存储队列有问题。 我有一个队列——“myQueue”和队列触发的azure函数“func1”。在host.json中,我配置了maxDequeueCount(5)和visibilityTimeout——一切都很好

5次尝试后,我的消息转到“myQueue poison”。 我有第二个azure函数“func2”(从func1复制粘贴),它是由“myQueue毒药”触发的队列。我还为此函数在host.json中设置了maxDequeueCount和visibilityTimeout。但此函数只触发一次—在第一次运行失败后,我的消息将从队列中消失。 发生了什么? host.json和c#代码是相同的-只是队列的名称不同

下面是函数1和函数2的代码

[FunctionName("Function1")]
        public static void Run([QueueTrigger("myqueue-poison", Connection = "AzureWebJobsStorage")]string myQueueItem, ILogger log)
        {
            Exception ex = new Exception();
            throw ex;
        }



 [FunctionName("Function2")]
        public static void Run([QueueTrigger("myqueue", Connection = "AzureWebJobsStorage")]string myQueueItem, ILogger log)
        {
            Exception ex = new Exception();            
            throw ex;
        }
示例日志消息,其中从毒药队列处理的消息有延迟

 [12/5/2018 9:39:16 PM] Loading functions metadata
    [12/5/2018 9:39:16 PM] 2 functions loaded
    [12/5/2018 9:39:17 PM] Generating 2 job function(s)
    [12/5/2018 9:39:17 PM] Found the following functions:
    [12/5/2018 9:39:17 PM] FunctionApp1.Function1.Run
    [12/5/2018 9:39:17 PM] FunctionApp1.Function2.Run
    [12/5/2018 9:39:17 PM]
    [12/5/2018 9:39:17 PM] Host initialized (662ms)
    [12/5/2018 9:39:17 PM] Host started (707ms)
    [12/5/2018 9:39:17 PM] Job host started
    Hosting environment: Production
    Content root path: C:\Users\username\source\repos\FunctionApp1\FunctionApp1\bin\Debug\netstandard2.0
    Now listening on: http://0.0.0.0:7071
    Application started. Press Ctrl+C to shut down.
    [12/5/2018 9:39:18 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=20bf83c5-3142-4092-9d85-7a2a6fbcf863)
    [12/5/2018 9:39:18 PM] Executed 'Function2' (Failed, Id=20bf83c5-3142-4092-9d85-7a2a6fbcf863)
    [12/5/2018 9:39:18 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
    [12/5/2018 9:39:18 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=49775db2-0c91-41cb-b472-a3aceee1bac3)
    [12/5/2018 9:39:19 PM] Executed 'Function2' (Failed, Id=49775db2-0c91-41cb-b472-a3aceee1bac3)
    [12/5/2018 9:39:19 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
    [12/5/2018 9:39:19 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=0a1d103a-41a0-4630-a479-c72297a368b8)
    [12/5/2018 9:39:19 PM] Executed 'Function2' (Failed, Id=0a1d103a-41a0-4630-a479-c72297a368b8)
    [12/5/2018 9:39:19 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
    [12/5/2018 9:39:19 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=6b79aad1-1eb6-4cfe-b39c-a7078f006968)
    [12/5/2018 9:39:20 PM] Executed 'Function2' (Failed, Id=6b79aad1-1eb6-4cfe-b39c-a7078f006968)
    [12/5/2018 9:39:20 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
    [12/5/2018 9:39:20 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=cf401aee-133d-42ac-a8e0-25fe95ebe162)
    [12/5/2018 9:39:20 PM] Executed 'Function2' (Failed, Id=cf401aee-133d-42ac-a8e0-25fe95ebe162)
    [12/5/2018 9:39:20 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
    [12/5/2018 9:39:20 PM] Message has reached MaxDequeueCount of 5. Moving message to queue 'myqueue-poison'.
    [12/5/2018 9:39:20 PM] Executing 'Function1' (Reason='New queue message detected on 'myqueue-poison'.', Id=2b1bd5ec-67e2-41c9-bd7b-6a3fde48cd04)
    [12/5/2018 9:39:21 PM] Executed 'Function1' (Failed, Id=2b1bd5ec-67e2-41c9-bd7b-6a3fde48cd04)
    [12/5/2018 9:39:21 PM] System.Private.CoreLib: Exception while executing function: Function1. FunctionApp1: Exception of type 'System.Exception' was thrown.
    [12/5/2018 9:39:22 PM] Host lock lease acquired by instance ID '0000000000000000000000004EE22C73'.
[12/5/2018 9:49:20 PM] Executing 'Function1' (Reason='New queue message detected on 'myqueue-poison'.', Id=83f83d31-44e6-46cf-a235-08360e5adc60)
[12/5/2018 9:49:21 PM] Executed 'Function1' (Failed, Id=83f83d31-44e6-46cf-a235-08360e5adc60)
[12/5/2018 9:49:21 PM] System.Private.CoreLib: Exception while executing function: Function1. FunctionApp1: Exception of type 'System.Exception' was thrown.
[12/5/2018 9:59:21 PM] Executing 'Function1' (Reason='New queue message detected on 'myqueue-poison'.', Id=54acbb91-d4db-4737-ae90-47b17df5998c)
[12/5/2018 9:59:21 PM] Executed 'Function1' (Failed, Id=54acbb91-d4db-4737-ae90-47b17df5998c)
[12/5/2018 9:59:21 PM] System.Private.CoreLib: Exception while executing function: Function1. FunctionApp1: Exception of type 'System.Exception' was thrown.

因此,看起来来自毒药队列的消息的读取方式与普通队列不同。是否有任何配置可用于减少毒药队列处理的延迟?

目前不支持这种情况

如果队列已经是毒药队列,则不会为毒药队列创建后续毒药队列。请看执行情况


由于您的毒药队列没有第二个毒药队列,因此当您的功能仍在运行时,消息不会被释放,即,您可能需要10分钟才能再次看到消息。请参阅实现。

您能否详细说明预期的行为、预期的原因以及代码正在执行的操作?函数记录消息并引发异常-我想测试重试。我预计func1将运行5倍并超时,例如30秒,func2将运行15倍并超时5min@blidea你的意思是,出列计数对毒药队列无效吗?@Baskar,是的,没错。是的,我通过创建一个简单的示例验证了它,消息从毒药-队列-公共静态类函数1出列后,将从毒药队列中清除{[FunctionName(“Function1”)]公共静态无效运行([QueueTrigger(“myqueue poison”,Connection=“AzureWebJobsStorage”)]字符串myQueueItem,ILogger日志){Exception ex=new Exception();log.LogInformation($“C#队列触发器函数已处理:{myQueueItem}”);抛出ex;}}