【问题标题】:Azure Functions QueueTrigger never firesAzure Functions QueueTrigger 从不触发
【发布时间】:2020-08-25 23:53:25
【问题描述】:

当数据添加到我指定绑定的队列时,我的队列触发器没有被激活。我有另一个持久函数,它接收一些 JSON 数据并将其放入该队列;我知道这很有效,因为我可以使用存储资源管理器看到数据出现在队列中。但是我的 queuetrigger 函数在数据到达队列后永远不会触发。

我知道它没有触发,因为总执行计数在门户中显示为 0。

完整的函数很长,所以我将分享我认为最相关的部分:

namespace Company.MySpecial
{
    public static class MySpecialQueueProcessor
    {
        [FunctionName("MySpecialQueueProcessor")]
        public static async void Run([QueueTrigger("myspecialqueue")]String transdata, 
        // various table mappings edited out
        ILogger log)
        {
            MySpecialItem Item = JsonConvert.DeserializeObject<MySpecialItem>(transdata);
            log.LogInformation($"[GROOVE-QUEUE] {Item.email} Queue processor activated");
        return;
        }
    }
}

我在那里有async,因为我需要调用一些需要await 运算符的任务,并且它不会让我在没有async 的情况下使用await。示例:

await MyData.AddAsync (Item);

并从表中检索数据:

                do
                {
                var page = await GrooveProductMappings.ExecuteQuerySegmentedAsync(productQuery, ct);
                ct = page.ContinuationToken;
                Matches.AddRange(page.Results);
                }
                while (ct != null); 

我不知道这是否是我的问题的一部分。

我的代码是否有问题,或者我在 Azure 中还没有完成其他需要它工作的事情?

【问题讨论】:

  • QueueTrigger 输入绑定在您的代码中缺少连接参数。我怀疑因为它没有连接到您想要的存储帐户(默认情况下,如果您不指定连接,它使用相同的功能主机存储)。 docs.microsoft.com/en-us/azure/azure-functions/…

标签: c# azure-functions


【解决方案1】:

我有三个问题:

  1. Function App Settings 中的 Queue Storage Account ConnectionString 设置是否正确?
  2. 您是否在 function.json“连接”属性中正确引用了该设置?
  3. 您是否在 function.json“queueName”属性中指向正确的队列?

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue-trigger?tabs=csharp#configuration

您还可以检查 Application Insights“实时指标”中的错误(如果您已为您的函数配置了它)

【讨论】:

  • #3 - 是的。 #2 - 在function.json 中,在bindings 下,列出了connection。但是,在您的第 1 点上,没有使用该名称的设置。我添加了一个具有该名称的设置,提供了通过 Azure 门户获得的连接字符串,它只是第一次工作!谢谢一百万!
  • 现在它可以工作了,我将发布一个单独的问题,因为它会为每个队列消息运行多次。
猜你喜欢
  • 2014-12-12
  • 1970-01-01
  • 2022-01-19
  • 2021-02-08
  • 2018-10-26
  • 1970-01-01
  • 2021-05-15
  • 2017-10-29
  • 1970-01-01
相关资源
最近更新 更多