【问题标题】:ServiceBusTrigger not found in basic Azure Function project在基本 Azure Function 项目中找不到 ServiceBusTrigger
【发布时间】:2021-09-04 21:47:12
【问题描述】:

我使用 Visual Studio 模板创建了一个全新的 .NET Core 3.1 Azure Function 项目

我正在使用V3的功能,即模板创建的版本

我有最新的 VS - 16.10.2

直接失败,ServiceBusTrigger 和 Connection not found?

使用系统; 使用 Microsoft.Azure.WebJobs; 使用 Microsoft.Azure.WebJobs.Host; 使用 Microsoft.Extensions.Logging;

namespace AzureFunctionTest
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([ServiceBusTrigger("AzureFunctionTest", "Research Subscription", Connection = "eventbus-connection")]string mySbMsg, ILogger log)
        {
            log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
        }
    }
}

真的很奇怪,MS 本身的模板是如何不起作用的,而且有点担心这在第一关就失败了!!

这是我的项目文件的相关部分

 <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.1.2" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
  </ItemGroup>

Azure.Messaging.ServiceBus 似乎是最新的包,也是推荐使用的包

我错过了什么?

保罗

【问题讨论】:

    标签: c# azure azure-functions azureservicebus


    【解决方案1】:

    您应该使用Microsoft.Azure.WebJobs.Extensions.ServiceBus 包。 Link.

    您可以阅读this官方文档了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-27
      • 2018-03-23
      • 2019-09-08
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 2018-08-06
      • 2022-07-04
      相关资源
      最近更新 更多