[Service Bus Extension] Support binding to ServiceBusReceivedMessage and POCO in the same function
See original GitHub issueLibrary name and version
Microsoft.Azure.WebJobs.Extensions.ServiceBus 5.3.0
Query/Question
I have code that was written using Microsoft.Azure.WebJobs.Extensions.ServiceBus v4.3.0 that was dead lettering the message if it didn’t pass validation:
internal sealed class ProcessEventFunction
{
private readonly MyEventValidator eventValidator;
public ProcessEventFunction(MyEventValidator? eventValidator)
{
this.eventValidator = eventValidator ?? throw new ArgumentNullException(nameof(eventValidator));
}
[Disable("DisableFunctions")]
[FunctionName(nameof(ProcessEventAsync))]
public Task ProcessEventAsync(
[ServiceBusTrigger("%EventTopicName%", "%SubscriptionName%", Connection = "ServiceBusConnection")]
MyEvent myEvent,
MessageReceiver messageReceiver,
string lockToken
)
{
ValidationResult validationResult = eventValidator.Validate(myEvent);
if (!validationResult.IsValid)
{
await messageReceiver.DeadLetterAsync(lockToken);
return;
}
// Process event
}
}
Note the use of the strongly typed message.
I am struggling to figure out how to migrate this to v5.3.0 while also still using strongly typed messages.
As #26564 rightly points out, there is currently nothing in the migration document that mentions sending messages to the Dead Letter Queue.
I did manage to find the Message Settlement section within the package’s readme file. Unfortunately, the mentioned ServiceBusMessageActions DeadLetterMessageAsync() method seems to only take a ServiceBusReceivedMessage and not a strongly typed message.
Can you please provide guidance on how to send a strongly typed message to the Dead Letter Queue using the v5.3.0 package?
Environment
Win64 Azure Function using .NET 6 in process model Visual Studio 17.1.3
Issue Analytics
- State:
- Created a year ago
- Comments:21 (10 by maintainers)
Top GitHub Comments
@JoshLove-msft consider this a vote for support for SDK types in Isolated Functions.
Hey Josh,
Thanks for the tip, and for commenting on the weekend, much appreciated!
That did fix the in process function for me and I’m now able to dead letter just fine.
I tried the same thing with the isolated function though, to see if I could figure out why the message was null and I received this error:
Exception: Microsoft.Azure.Functions.Worker.FunctionInputConverterException: Error converting 1 input parameters for Function 'CreateSeasonTrigger': Cannot convert input parameter 'message' to type 'Azure.Messaging.ServiceBus.ServiceBusReceivedMessage' from type 'System.String'.
I’ll need to scour the docs again to find the right way to handle this with isolated functions as we will be migrating to them with .NET 7 this fall.