如何使用 Azure Functions 输出绑定设置服务总线消息的 MessageId?

How can you set the MessageId of a Service Bus message using the Azure Functions output binding?

如何使用 Azure Functions 输出绑定设置服务总线消息的 MessageId?

我在预编译的 C# Function App 中使用以下输出绑定可以很好地写入 SB 主题的函数...

[ServiceBus("targettopic", Connection = "SbConnectionString")]
    out PersonEvent outPerson,

但我需要设置 MessageId 以在重复检测历史记录中使用

您必须 return 一个 BrokeredMessage 类型的实例,而不是您的自定义 class。这将使您能够设置任何 属性 包括消息 ID。