使用服务总线资源管理器创建的 Azure 主题订阅规则未触发
Azure Topic Subscription Rule created with Service Bus Explorer not triggering
我正在使用服务总线资源管理器作为测试通过 ARM 部署时不起作用的规则的快速方法。
在 Azure 函数的 JavaScript 中,我将主题消息设置为:
context.bindings.outputSbMsg = { Indicator: 'Itinerary'};
在 Service Bus Explorer 中,我使用以下字符串设置订阅规则:
Indicator = 'Itinerary'
但是发送到主题的消息不会转到此订阅(它们转到另一个规则 1 = 1)
问题:我在这里缺少什么?
补充信息:
我似乎无法访问指标 属性。作为测试,我在附加到指标 属性 的 1=1 规则上创建了一个操作,结果为空。
如果我有一个由 1 = 1 规则触发的函数,我可以访问 JavaScript 中的指标 属性,因此 属性有吗
该规则无效,因为
- 该规则适用于系统或用户定义的属性,而不适用于邮件正文。
- js函数输出的只是消息体,即
context.bindings.outputSbMsg = { Indicator: 'Itinerary'};
发送消息{ Indicator: 'Itinerary'}
,没有属性我们设置
并且带有 1=1 true 过滤器的默认规则允许将所有消息选择到订阅中,因此您会看到消息一直发送到那里。查看 doc of topic filters 了解更多详情。
目前,js 函数输出无法填充消息属性。为了使过滤器工作,我们必须使用 SDK 发送带有 属性 的消息。安装 azure-sb
包然后尝试下面的示例代码。
const azuresb = require("azure-sb");
const connStr = "ServiceBusConnectionString";
const mytopic = "mytopic";
var serviceBus = azuresb.createServiceBusService(connStr);
const msg =
{
body: "Testing",
customProperties: {
Indicator: 'Itinerary'
}
};
serviceBus.sendTopicMessage(mytopic, msg, function(error) {
if (error) {
context.log(error);
}
else{
context.log("Message Sent");
}
});
我正在使用服务总线资源管理器作为测试通过 ARM 部署时不起作用的规则的快速方法。
在 Azure 函数的 JavaScript 中,我将主题消息设置为:
context.bindings.outputSbMsg = { Indicator: 'Itinerary'};
在 Service Bus Explorer 中,我使用以下字符串设置订阅规则:
Indicator = 'Itinerary'
但是发送到主题的消息不会转到此订阅(它们转到另一个规则 1 = 1)
问题:我在这里缺少什么?
补充信息:
我似乎无法访问指标 属性。作为测试,我在附加到指标 属性 的 1=1 规则上创建了一个操作,结果为空。
如果我有一个由 1 = 1 规则触发的函数,我可以访问 JavaScript 中的指标 属性,因此 属性有吗
该规则无效,因为
- 该规则适用于系统或用户定义的属性,而不适用于邮件正文。
- js函数输出的只是消息体,即
context.bindings.outputSbMsg = { Indicator: 'Itinerary'};
发送消息{ Indicator: 'Itinerary'}
,没有属性我们设置
并且带有 1=1 true 过滤器的默认规则允许将所有消息选择到订阅中,因此您会看到消息一直发送到那里。查看 doc of topic filters 了解更多详情。
目前,azure-sb
包然后尝试下面的示例代码。
const azuresb = require("azure-sb");
const connStr = "ServiceBusConnectionString";
const mytopic = "mytopic";
var serviceBus = azuresb.createServiceBusService(connStr);
const msg =
{
body: "Testing",
customProperties: {
Indicator: 'Itinerary'
}
};
serviceBus.sendTopicMessage(mytopic, msg, function(error) {
if (error) {
context.log(error);
}
else{
context.log("Message Sent");
}
});