Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
418 stars 182 forks source link

Allow Middleware to alter Functions output for ServiceBus Message Binding #2327

Open iainrobins-ab opened 7 months ago

iainrobins-ab commented 7 months ago

Description

Similar to the issue reported here - https://github.com/Azure/azure-functions-dotnet-worker/issues/340

I have a requirement to use Middleware in Isolated Functions to add metadata to Service Bus messages on all Functions that are publishing messages. Such as Subject/Label, Correlation ID, etc.

In Middleware you can seemingly access the Binding and see the value of the Body of the message you will send, but there is no ability to set the Message Headers.

Is it possible to expose this functionality similar to how you can alter an HTTP Response?

SeanFeldman commented 7 months ago

Have you tried FunctionContext.GetOutputBindings<>() to see if it could help?

kshyju commented 6 months ago

As of today, output binding supports only POCOs or primitive types. So there is no way to define/update the metadata properties of your message.

See https://github.com/Azure/azure-functions-dotnet-worker/issues/681#issuecomment-977256500

We are waiting on https://github.com/Azure/azure-sdk-for-net/issues/21884 to be done. Once that is done, the out-of-process model can add the support for customizing the meta properties of the message.

cc @mattchenderson

iainrobins-ab commented 6 months ago

Thanks for the update kshyju, I'll watch that issue for resolution.