azure-webjobs-sdk: Support triggering a single function on multiple queues (wildcard queue name)

Example scenario: A webjob that monitors all *-poison queues in a storage account, with a single generic action taken on all (e.g. write queue message to blob for inspection, email/Slack/SMS to ops team to alert of failure).

I’ve looked into implementing this as an extension, but rapidly ended up with 90% of the code being duplication of the core SDK due to much of the infrastructure behind QueueTriggerAttribute being marked as internal.

Would you be willing to consider a pull request that creates a MultipleQueueTriggerAttribute that accepts a regex to match against queue names, creates a listener monitoring all matching queues and adds a queueName binding in addition to the existing bindings?

public static void HandlePoisonQueues(
    [MultipleQueueTriggerAttribute(".*-poison")] string message,
    string queueName,
    [Blob("poison/{queueName}/{id}.txt")] TextWriter blob,
    TextWriter logger)
{
    logger.WriteLine($"Poison message received on {queueName}")
    blob.Write(message);
}

About this issue

  • Original URL
  • State: open
  • Created 10 years ago
  • Reactions: 32
  • Comments: 29

Most upvoted comments

Has anyone from Microsoft had a look at this, and is it on the backlog?

For massive scale and better tenancy isolation, 1 queue per tenant would be ideal - but that would also require one function binding per queue too, which is far from ideal (and likely to hit some scaling limitation, which are rife throughout all Azure services)

Bueller? At 5 years and ticking, this would be nice to have.

After five years, any progress or update? At least a workaround?

Any updates? Has anyone found a workaround for this?

I think if you need this it’s an indication of poor design

On Wed, Jan 25, 2023, 7:46 AM Aaron Schmid @.***> wrote:

Would be kinda cool if we can have this 😃

— Reply to this email directly, view it on GitHub https://github.com/Azure/azure-webjobs-sdk/issues/808#issuecomment-1403649243, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAIE336I4YAEPARR4WJYWLWUEVFFANCNFSM4COKFDKA . You are receiving this because you commented.Message ID: @.***>

I need a function to be triggered by multiple queues. Any progress here?

Another interesting and useful scenario:

To overcome the Azure Storage Queue scalability limits more easily.

A single queue can process approximately 2,000 messages (1KB each) per second (each AddMessage, GetMessage, and DeleteMessage count as a message here). If this is insufficient for your application, you should use multiple queues and spread the messages across them.

Defining a Regex on the queue name: [MultipleQueueTriggerAttribute(“orders[0-9]”)] string message

Passsing several queue names: [MultipleQueueTriggerAttribute(“orders1”, “orders2”, “orders3”)] string message

Gut shabbos!

On Thu, Jan 26, 2023, 3:19 AM Simon-Gregory-LG @.***> wrote:

Fantastic, it seems we’ve stumbled across a pro design expert!

Maybe you could bless us with some of your wisdom on how best to tack a couple of example scenarios: Priority Queue Triggers

Say you have n queues that represent different ‘priorities’ and you want to process them in some predetermined priority order using a scalable Azure Function. Techniques could be either to exhaust the queues in order of their priority, or even to pop each batch guided by some target proportional ratio (e.g. 3 queues High, Medium, Low you want to trigger in batches of 10 in the ratio 6:3:1).

To achieve this in Azure Functions you could use a TimerTrigger and roll your own logic. However timer triggers are limited to be used on one instance only so are not scalable and would require additional custom logic for exponential backoff outside of peak times etc which TimerTriggers do by default. If MultipleQueueTriggers existed I imagine it would have some kind of ordering logic to pop queues using some predetermined processing logic and seem to me to be a very natural way to solve this problem out of the box.

But maybe I’m missing something, could it be that:

  • Priority Queues are an antipattern and should never be used?
  • Systems shouldn’t have load / scaling requirements beyond what can be done with a single timer trigger?
  • Azure Queues and/or Service Bus already possess little known intrinsic queue prioritisation functionality?
    • AFAIK they don’t. I know Service Bus has additional functionality with sessions etc, but you still can’t do implement ratio exhaustion method with that.
  • We shouldn’t be using Azure Functions to process queues?
  • Something else?

Bulk Handling Poison Queues

This is effectively the use-case as described in the original question. You have n queues and you want to process any of their poison messages in the same manner using an Azure Function. Should we write n functions to handle each, or deploy n function AppServices each hosting their own function app configured for each queue?

I have some sympathy that wildcards might be an antipattern / open to abuse, but surely a MultipleQueueTrigger would be a natural solution for this, even if the queue names are defined / updated in the configuration.

Or maybe:

  • We should all be using just one queue for everything?
  • We should ensure that queue messages can never end up on poison ever, for any reason?
  • We should be using the non-scalable TimerTrigger mechanism and roll our own?
  • Each queue function should be developed with a partner poison method in every app (even if they are all to do the same thing), because mass code duplication isn’t the antipattern that everybody thinks it is?
  • Something else?

Thanks for your insight and valuable contribution.

— Reply to this email directly, view it on GitHub https://github.com/Azure/azure-webjobs-sdk/issues/808#issuecomment-1404733405, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAIE32D7PLB5U7KSFZNOS3WUI6TTANCNFSM4COKFDKA . You are receiving this because you commented.Message ID: @.***>