首页 > 解决方案 > 绑定类型“serviceBusTrigger”未注册

问题描述

我有一个时间触发的 Azure 函数,我通过它在我的 Azure 服务总线主题中推送一些消息。现在,期望是每当在主题中接收到消息时,它将触发另一个主题触发函数。不幸的是,当我通过服务总线资源管理器工具检查主题订阅中的消息时,它没有显示收到任何消息。我也可以在功能控制台中看到这个错误: The 'myFunc' function is in error: The binding type(s) 'serviceBusTrigger' are not registered. Please ensure the type is correct and the binding extension is installed

我不确定我在哪里出错了。我已经像这样定义了我的主题触发函数:

   [FunctionName("myFunc")]
                public async Task Run([ServiceBusTrigger("topic-name", "subs-name", Connection = "ServiceBusConnectionString")]string message, ILogger log)
                { ... }

请注意,我已经安装了最新版本的Microsoft.Azure.WebJobs& Microsoft.Azure.WebJobs.ServiceBus (但不知道为什么两者都显示警告)。是因为版本有问题吗?

在此处输入图像描述

我的主机.json:

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "fun_name": "Information"
    }
    }
 }

标签: azure-functionsazureservicebus

解决方案


这是我这边的 .csproj 文件,它在本地运行良好。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

在此处输入图像描述

应该没有问题,您可能会遇到组件冲突。


推荐阅读