【问题标题】:V2 Azure Function ServiceBusTrigger Not WorkingV2 Azure 函数 ServiceBusTrigger 不工作
【发布时间】:2018-09-13 19:20:21
【问题描述】:

我有一个定义 Azure 函数的 .NET Standard 2.0 项目。我有几个按预期工作的 BlobTrigger 和 QueueTrigger 函数。我正在尝试用 ServiceBus 主题触发函数替换存储帐户 QueueTrigger 函数:

[FunctionName("CommandConsumer")]
public static async Task RunAsync([ServiceBusTrigger("commands", "active", Connection = "ServiceBus")]string commandJson, TraceWriter log)
{
    log.Info($"C# ServiceBus topic trigger function processed message: {commandJson}");
}

即使上游函数成功向主题添加消息(我可以看到我现在有 25 条关于该主题的消息),此函数也不会被触发,并且我的控制台窗口显示了很多这样的消息:

[9/13/2018 7:13:29 PM] MessageReceiver error (Action=Receive, ClientId=MessageReceiver1commands/Subscriptions/active, EntityPath=commands/Subscriptions/active, Endpoint=p.servicebus.windows.net)
[9/13/2018 7:14:06 PM] MessageReceiver error (Action=Receive, ClientId=MessageReceiver1commands/Subscriptions/active, EntityPath=commands/Subscriptions/active, Endpoint=p.servicebus.windows.net)
[9/13/2018 7:14:42 PM] MessageReceiver error (Action=Receive, ClientId=MessageReceiver1commands/Subscriptions/active, EntityPath=commands/Subscriptions/active, Endpoint=p.servicebus.windows.net)

我已将跟踪设置为 Verbose,但我无法获得有关此 MessageReceiver 错误的更多详细信息。

提前谢谢你!

编辑:这里是项目的相关包参考:

<PackageReference Include="Microsoft.Azure.ServiceBus" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0-beta8" />
<PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="3.0.0-beta8" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.19" />

【问题讨论】:

  • 根据您的错误信息,您发送消息时似乎需要检查消息的类型。另外,当您将消息发送到 v2 时,平台是什么。
  • 向主题发送消息没有错误:public async Task&lt;bool&gt; SubmitAsync&lt;T&gt;(IEnumerable&lt;T&gt; commands) where T : Command { var messages = commands.Select(c =&gt; new Message(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(c)))); await topicClient.SendAsync(messages.ToList()); return true; }

标签: azure azure-functions azureservicebus


【解决方案1】:

我们在 Azure 模板中犯了一个错误,并为某些 KeyVault 访问密钥复制了密钥,这导致 Azure 函数的调用失败,因为对 KeyVault 的“访问被拒绝”。不幸的是,在本地运行时,输出窗口没有显示那些内部异常,但是当我们在 Azure 中运行相同的代码时,我们在 Live Metrics Stream 中看到了异常,并且能够追踪并修复重复的键。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-22
    • 1970-01-01
    • 2019-09-30
    • 1970-01-01
    相关资源
    最近更新 更多