azure-functions-host: Support for not so custom TriggerBinding
Question
Azure Functions do not support custom TriggerBinding
s. There is a good explanation of the reasons provided by Coby and @jeffhollan at the April Azure functions live. As far as I can understand the problem boils down to Scale Controller not having information about custom trigger and not being able to scale the function app when needed. One example might be a function reacting to stream of tweets.
That being said what if the custom trigger would be based on a source that is already supported by the existing trigger e.g. Azure Storage Queue? I’ve been working on a spike that creates a custom trigger for ASQ and it looks that the Scale Controller handles the auto-scaling properly if I make my trigger pretend it’s queueTrigger
. In practice it means I provide function.json
content as if it was queueTrigger
.
Are there any plans to support customs triggers at that level?
Background information
What I’m asking is a potential solution to a problem that I am trying to solve. What I would like to do is provide Azure Function users with capability to receive custom POCO types as input messages and be able to pass message headers between input message and any outgoing message that goes out via output collector. It would be also great if I could handle any custom message serialization behind the scenes. Something like this.
I would be really grateful for any suggestions.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 5
- Comments: 28 (12 by maintainers)
@paulbatum So you agree the change is good, but the team has no time. Is there a way community could contribute to this? I guess NServiceBus guys and other geeks like me 😃 could spend their time on features that they find valuable. Embrace the open source, you know.
Obviously some effort from the team would still be required. But isn’t that the higher priority work then - helping others to help you?
One obvious problem is lack of scale controller open code, but I’m not sure how many changes are needed there.
OK I spent a bunch of time playing with this. The TL;DR is that in general, you can use the extensions model to add additional types that user code can bind to, without having to implement a custom trigger itself. The example I used was a wrapping type for EventData (from the event hubs extension). The extension is just:
I was able to write and execute an event hub triggered function that used this extension:
However, Tomasz is correct with his observations about the queue trigger. It seems like it doesn’t participate correctly in the extensibility model so if you tried to do the same as above but for a queue triggered function it would not work. I have filed this issue to track: https://github.com/Azure/azure-webjobs-sdk/issues/1696
I think it makes sense to leave this issue open, because not ALL scenarios can be handled with a custom converter. You might want to change the retry or error semantics for a given trigger type while still relying on the standard scale controller monitoring behavior for activation and scale out. But for all the scenarios where you just want to add the ability to use a new type from the function code, I would suggest using the approach outlined above (which would be viable for queue triggers if that 1696 issue is resolved).
@paulbatum first of all thank you for your insights and comments.
Let me try sharing context from my end.
As mentioned in the issue description custom trigger is a solution to a set of problems that I was trying to tackle. Let me try describe them in more detail in context of asq trigger:
In general those overlap with scenario mentioned by @mikhailshilkov in which it’s hard to provide a business level function signature (business data as input types) and float control data behind the scenes.
To clarify - my reply was to Mikhail, just saw your post Tomasz, thanks for the info.
@paulbatum I would not necessarily categorize custom bindings/triggeres as a few lines of code saved for users. Take for example @tmasternak 's original question. He’d like to enable NServiceBus customers to use Functions. It is more than just a few lines of code.
Another example (ironically, asked by an internal MSFT team) is to use Functions with Azure Service Bus to support messages larget than 1 MB to migrate from MSMQ. There’s a plugin for ASB seamlessly implementing claim check pattern. The existing Service Bus trigger doesn’t support plugins registration. That would mean duplicating what plugin is doing in all of their functions and owning that implementation rather than focusing on core busines requirement.
I understand the desire to focus on the lower hanging fruits. At the same time, would not understimate the ability to create custom triggers that are first class citizens when it comes to scale, rather than just nice demos for blog posts 🙂