c# - Azure 服务总线触发功能 - 绑定(bind)到 MessageReceiver

标签 c# azure .net-core azureservicebus azure-servicebus-topics

我正在尝试绑定(bind)到 Azure 服务总线触发函数中的 MessageReceiver
我的目标是处理死信队列消息并完成它们。

    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task Run(
                [ServiceBusTrigger(
                        "<topicName>", 
                        "<subscriptionName>/$DeadLetterQueue", 
                        Connection = "connectionstring")] 
                        Message message,
                        ILogger logger,
                        MessageReceiver messageReceiver)
        {
            // TODO: Perform some actions

            await messageReceiver.CompleteAsync(message.SystemProperties.LockToken);
        }

问题在于它无法绑定(bind)到 MessageReceiver 类。

Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'receiver' to type MessageReceiver. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

对于绑定(bind)失败的原因有什么想法吗?

最佳答案

我知道出了什么问题了。我使用“receiver”作为 MessageReceiver 的参数名称。结果发现参数名称必须是“messageReceiver”。我查看的示例首先使用了“接收器”,那么这可能已经发生了变化吗?

关于c# - Azure 服务总线触发功能 - 绑定(bind)到 MessageReceiver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59775120/

相关文章:

c# - CheckBox IsChecked 和 IsMouseOver

c# - 如何在 C# (Unity) 中设置对象的最大旋转

azure - VMWare到Azure - 多个VMDK文件,如何处理?

c# - 通过 c#/dotnet 核心中的命名管道卸载到 ffmpeg

.net-core - 指定的 deps.json[] 不存在 - Blazor WebAssembly App 项目类型

c# - 在 MVVM 中打开一个新窗口

azure - 如何修复发布 Azure Functions 时出现的 "Validate Connection"错误“找不到 testMsDeployConnection”?

在阶段之间传播期间第二次访问时,Azure Pipeline 变量值会丢失

c# - 如何在类/独立线程 ASP.Net Core 中使用 ApplicationDbContext

c# - objectlistview 如何更改组标题中的文本?