I was following an example that targeted v1 Functions and what I want from it I haven't been able to replicate in v2.
I want the BrokeredMessage in the signature of the Azure Function.
public static async Task WhatIsTheTime(
[ServiceBusTrigger(queueName: QueueName, Connection = ConnectionStringKey)]
BrokeredMessage message,
ILogger log)
{
var myObj = message.GetBody<MyType>();
// whatever
}
primarily because it includes lots of handy metadata and I cba to change the signature every time I decide I want something different. Also because as the above example shows, its pretty easy to get the body.
However it seems like whatever out-of-the-box setup I have is furious at this idea. What it wants me to do is:
public static async Task WhatIsTheTime(
[ServiceBusTrigger(queueName: QueueName, Connection = ConnectionStringKey)]
MyType myObj,
ILogger log)
{
// whatever
}
and do that first step for me.
If I do this, everything is happy and we can all go home. However I don't want this, I'd rather the full BrokeredMessage.
No matter how I tried packaging the content of the body it failed miserably prior to my code executing giving me a host of different errors (depending on how I packaged it) but tellingly; this one:
Exception while executing function: Exception binding parameter Expecting element 'BrokeredMessage'
Where its trying to deserialize the BODY of a BrokeredMessage into a BrokeredMessage!
What gives? I've read articles that state putting BrokeredMessage in the signature makes this stuff easy. Am I missing a configuration option or smth?