简体   繁体   English

azure功能服务总线输出消息属性

[英]azure function service bus output message properties

I'm trying to set metadata for service bus messages in a JavaScript Azure Function using the service bus binding output. 我正在尝试使用服务总线绑定输出在JavaScript Azure功能中设置服务总线消息的元数据。 Unfortunately, it appears that the binding only supports the body. 不幸的是,似乎绑定只支持身体。

Looking at the docs, I see that you can access this information in service bus triggers via context.bindingData but I don't see any corresponding interface for service bus output. 查看文档,我看到您可以通过context.bindingData在服务总线触发器中访问此信息,但我没有看到任何相应的服务总线输出接口。

Is there some way to send a full brokered message and set the message properties (ContentType) and message custom properties ? 有没有办法发送完整的代理消息并设置消息属性 (ContentType)和消息自定义属性 在此输入图像描述

There is an open issue for this at https://github.com/Azure/Azure-Functions/issues/454 有一个未解决的问题,请访问https://github.com/Azure/Azure-Functions/issues/454

Some customers seemed to have found a workaround. 一些客户似乎找到了解决方法。 Perhaps you can try their approach mentioned here https://github.com/Azure/Azure-Functions/issues/454#issuecomment-375154151 也许你可以尝试他们在这里提到的方法https://github.com/Azure/Azure-Functions/issues/454#issuecomment-375154151

@l--''''''---------'''''''''''' You need to access the Microsoft.Azure.ServiceBus.Message class. @l --''''''---------“”“”“”“”“”“”你需要访问Microsoft.Azure.ServiceBus.Message类。 Let's say you have some json called messageBody 假设你有一些名为messageBody json

and you have some list of properties that you want to add to the message. 并且您有一些要添加到邮件中的属性列表。 You can achive it like the below example. 您可以像下面的示例一样实现它。

Make sure you add using Microsoft.Azure.ServiceBus; 确保using Microsoft.Azure.ServiceBus;添加using Microsoft.Azure.ServiceBus;

var myCustomProperties = new List<Dictionary<string,string>>();
var message = new Message(Encoding.UTF8.GetBytes(messageBody));
foreach (var userProperty in myCustomProperties)
{
  message.UserProperties.Add(userProperty.Key, userProperty.Value);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM