javascript - Azure 函数服务总线输出消息属性

标签 javascript node.js azure azure-functions azureservicebus

我正在尝试使用服务总线绑定(bind)输出在 JavaScript Azure 函数中设置服务总线消息的元数据。不幸的是,绑定(bind)似乎只支持正文。

查看文档,我发现您可以通过 context.bindingData 在服务总线触发器中访问此信息,但我没有看到服务总线输出的任何相应接口(interface)。

是否有某种方法可以发送完整的代理消息并设置消息属性(ContentType)和消息自定义属性enter image description here

最佳答案

@l--''''''---------'''''''''''' 您需要访问 Microsoft.Azure.ServiceBus.Message 类。假设您有一些名为 messageBody

的 json

并且您有一些要添加到消息中的属性列表。您可以像下面的示例一样实现它。

确保添加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);
}

关于javascript - Azure 函数服务总线输出消息属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52901360/

相关文章:

javascript - 按钮仅在重新加载后第二次单击时起作用

javascript - ng-websocket 和 ws : client sends successfully but doesn't receive

azure - 有没有办法根据 Runbook/自动化脚本的标签删除资源组?

Azure DevOps - 测试运行管理 : resuming in-progress test

javascript - 当 x 可能有多种类型时,如何知道 x 是什么

javascript - Ace 编辑器和 vim 键绑定(bind) : using :w command

javascript - CSS + jquery 响应式背景颜色变化

javascript - 返回自定义 promise

node.js - 如何在 foreach 循环中使用多个异步等待调用将返回值推送到数组中

.net - 我可以从 Azure Web 角色入口点访问 web.config 吗?