简体   繁体   中英

How to use a ServiceBus Trigger with a topic/subscription in an Azure Function

I'd like to create an Azure Function that is triggered when a new message is added to a topic/subscription.

For the moment I've created an Azure Function using the ServiceBusQueueTrigger C# Template and I've set the Queue Name to

topicPath + "/Subscriptions/" + subscriptionName

Azure Functions ServiceBusQueueTrigger C#模板

But I've got this 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函数中使用主题/订阅创建ServiceBusTrigger

I thought the Azure Function was using the MessagingFactory.CreateMessageReceiver to initialize the message pump but not.

Is there any support for topic/subscription for the moment ?

Yes topics are supported, but our UI and templates are behind on that unfortunately - we'll be releasing some updates soon addressing these issues.

For now, you can use the Advanced Editor to edit your trigger binding directly. There you can specify your subscriptionName and topicName values. Here's an example:

{
  "bindings": [
    {
      "type": "serviceBusTrigger",
      "name": "message",
      "direction": "in",
      "subscriptionName": "subscription-test",
      "topicName": "topic-test",
    }
  ]
}

In general, since Azure Functions is build atop the WebJobs SDK, our various bindings are mapped directly to their SDK counterparts. For example serviceBusTrigger maps to ServiceBusTriggerAttribute which has SubscriptionName / TopicName properties. Therefore, expect to see the same properties in the Function metadata model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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