【问题标题】:Azure function with .net core 3.1 not triggering from Queue storage具有 .net core 3.1 的 Azure 功能未从队列存储触发
【发布时间】:2020-09-15 05:04:22
【问题描述】:

我正在尝试在添加新队列消息时触发 Azure 函数。存储账户和天蓝色函数都在同一个区域。

对于我的 Azure 函数,我点击了添加,Azure 队列存储触发器,我给我的函数命名,队列名称与我的队列名称相同。我尝试添加一个新的队列消息,没有任何触发。

然后我尝试修改代码如下:

using System;

[FunctionName("QueueTrigger")]
[StorageAccount("storagetestaccount1")]

public static void Run(
    [QueueTrigger("queue1")] string myQueueItem, 
    ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}

但仍然没有成功。知道是什么原因造成的吗?

这是我的第一个天蓝色函数,所以不确定什么是正确的,什么不是。

【问题讨论】:

  • 使用这个:[QueueTrigger("myqueue-items", Connection = "StorageConnectionAppSetting")] 那么一切都应该没问题。您是在本地开发还是在 azure 上开发?

标签: azure azure-functions azure-function-app azure-queues azure-storage-queues


【解决方案1】:

我认为正确的代码是这样的:

    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([QueueTrigger("queueName", Connection = "connectString")]string myQueueItem, ILogger log)
        {
            log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
        }
    }

注意

如果你在本地开发,你应该在local.settings.json中配置你的Azure存储连接字符串

如果是azure portal开发,需要在Application settings中配置连接字符串:

【讨论】:

    猜你喜欢
    • 2020-04-21
    • 1970-01-01
    • 2021-10-30
    • 2018-04-24
    • 2019-03-26
    • 2020-08-17
    • 2021-07-07
    • 2020-10-15
    • 1970-01-01
    相关资源
    最近更新 更多