1
votes

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# Template

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 ''. .

Failed to create ServiceBusTrigger with Topic/Subscription in an Azure Function

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 ?

1

1 Answers

6
votes

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.