我面临在JavaScript的azure函数中向azure服务总线输出发送完整的代理消息的问题. 该文档仅显示一条简单的正文消息 docs.microsoft/zh-CN/azure/azure-functions/functions-bindings-service-bus 而没有任何customerProperties.
I'm facing issue to send a complete brokered message to an azure service bus output in azure function in javascript. The documentation only show a simple body message docs.microsoft/en-us/azure/azure-functions/functions-bindings-service-bus without any customerProperties.
到目前为止,我尝试创建完整的代理消息的尝试均失败了,一切都变得顺利了.
My attempts to create a full brokered message failed so far, everything goes into the body.
var message = {'body' : 'test', 'customProperties' : {'fromsystem':'sap'}}; context.bindings.outputSbMsg = message; context.done(null, res);
推荐答案
不幸的是,这是节点的局限性之一,因为我们丢失了一些C#中的类型信息.
Unfortunately this is one of the limitations of node, as we lose some type information that we have in C#.
您可能试图发送带有自定义属性的body为test的消息,但是您也可能尝试以body子属性的形式发送整个对象作为主体. Azure Functions假定您返回的所有内容都应进入主体.
You could be trying to send a message with a body of test with custom properties, but you could also be trying to send the entire object as the body, with a body sub-property. Azure Functions make the assumption that everything that you return should go into the body.
作为解决方法,您可以:
As a workaround, you could:
- 放弃输出绑定,并直接将 ServiceBus sdk用于节点
- 使用C#或F#代替实际的BrokeredMessage类型
- 让您的node函数将结果放入队列,然后触发C#函数创建您想要的确切BrokeredMessage
- ditch the output binding and use the ServiceBus sdk for node directly
- instead of node, use C# or F# with the actual BrokeredMessage type
- have your node function put the result into a queue, which then triggers a C# function to create the exact BrokeredMessage you want
更多推荐
通过azure功能在azure服务总线中发送完整的代理消息
发布评论