Home > OS >  Isolated process Azure Function with optional ServiceBusOutput return value
Isolated process Azure Function with optional ServiceBusOutput return value

Time:09-27

I'm using an isolated process Azure Function with an output binding to Service Bus.

The documentation doesn't mention what to do in the case that there's no need to queue another message (e.g. if my processing code throws, I don't want want to keep queueing).

IAsyncCollector and ICollector are no longer supported in isolated process. So is returning null good enough to prevent it from queueing?

CodePudding user response:

If there are no messages to enqueue, return an empty IEnumerable, not null. That way, Functions Worker SDK will iterate over no objects to turn into messages for dispatching. While null might work (I haven't validated it), it seems better to return an empty collection than a null.

In case your function is failing, let it fail. Don't try swallowing the exception and returning something you shouldn't have been returning, to begin with.

  • Related