我想创建一个 Azure Functions,当新消息添加到主题/订阅时触发。
目前我创建了一个 Azure Function使用 ServiceBusQueueTrigger C# 模板 并将队列名称设置为
topicPath + "/Subscriptions/" + subscriptionName
但是我有这个异常(exception):
Microsoft.ServiceBus: Cannot get entity 'topic-test/Subscriptions/subscription-test' because it is not of type QueueDescription. Check that you are using method(s) with the correct entity type. System.Runtime.Serialization: Error in line 1 position 1762. Expecting element 'QueueDescription' from namespace 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'.. Encountered 'None' with name '', namespace ''. .
我以为 Azure 函数使用的是 MessagingFactory.CreateMessageReceiver初始化消息泵但不初始化。
目前是否支持主题/订阅?
最佳答案
是的,支持主题,但不幸的是,我们的 UI 和模板落后于此 - 我们将很快发布一些更新来解决这些问题。
目前,您可以使用高级编辑器直接编辑触发器绑定(bind)。您可以在那里指定您的 subscriptionName
和 topicName
值。这是一个例子:
{
"bindings": [
{
"type": "serviceBusTrigger",
"name": "message",
"direction": "in",
"subscriptionName": "subscription-test",
"topicName": "topic-test",
}
]
}
一般来说,由于 Azure Functions 构建在 WebJobs SDK 之上,我们的各种绑定(bind)直接映射到对应的 SDK。例如 serviceBusTrigger
映射到 ServiceBusTriggerAttribute它具有 SubscriptionName
/TopicName
属性。因此,期望在函数元数据模型中看到相同的属性。
关于c# - 如何在 Azure 函数中使用带有主题/订阅的服务总线触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36707496/