azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[BUG]Isolated Service Bus Trigger with Object parameter type body is empty
Library name and version
Microsoft.Azure.Functions.Worker.Extensions.ServiceBus 5.18.0
Describe the bug
I migrated my Azure Function from .Net 6 In-Process to .Net 8 Isolated model.
However, some of my service bus trigger functions with
[ServiceBusTrigger("%MyServiceBusQueue%", Connection = "ServiceBusConnection")] MyCutomTypeMessage myMyCutomTypeMessage
have myMyCutomTypeMessage is empty {} when triggerred.
Now I can only use ServiceBusReceivedMessage to get body then deserialise to my MyCutomTypeMessage type.
[ServiceBusTrigger("%ServiceBusWasteTrackCollectionExceptionsQueue%", Connection = "ServiceBusConnection")] ServiceBusReceivedMessage serviceBusReceivedMessage, FunctionContext context
var serviceBusMessageString = serviceBusReceivedMessage.Body.ToString(); var collectionException = JsonConvert.DeserializeObject<MyCutomTypeMessage >(serviceBusMessageString);
Not sure if it has something to do with DI:
services.AddMvcCore().AddNewtonsoftJson();
Interestingly, some other servicebus trigger function within the same function app are still working fine.
Expected behavior
The plan Object type should work as per doc:
When a message contains JSON, Functions tries to deserialize the JSON data into known plain-old CLR object type.
Actual behavior
The message triggered function is empty
Reproduction Steps
- Migrate a service bus trigger funciton with a Object parameter type from .Net6 in-process to .Net 8 isolated
- Add
services.AddMvcCore().AddNewtonsoftJson();in DI - Run the function and print the service bus message, it is empty
Environment
VS 2022 .NET 8
Thank you for your feedback. Tagging and routing to the team member best able to assist.
Hi @HaochenQ. Thank you for reaching out and we regret that you're experiencing difficulties. Using a POCO is a supported scenario for the isolated worker and one that we validate as part of our test runs. We're not seeing test failures, we're not seeing other developers have these failures, and we're unable to reproduce the behavior that you're seeing.
Generally, these failures often come down to a type mismatch between the message body and the type expected by the trigger. Given that you're able to manually deserialize, a full type mismatch seems unlikely. It may come down to a mismatch between serialization formats for your specific type, due to your AddNewtonsoftJson call. I'd suggest testing without that line and seeing if you're able to reproduce.
If that doesn't resolve your issue, we'll need to ask that you provide a small, self-contained app that reproduces the behavior for us, as we're unable to do so.
Hi @HaochenQ. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
Hi @HaochenQ, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!