I am creating an Azure Function that is a ServiceBus Trigger.
[FunctionName("RetryRack")]
public async Task Run([ServiceBusTrigger("%RackIntegration:topic%", "%RackIntegration:subscription%")] ServiceBusReceivedMessage sbMessage, ILogger log, MessageReceiver messageReceiver)
I am using Azure.Messaging.ServiceBus (7.6.0).
I have several custom properties that I sent in the messages when I send them using ServiceBusMessage from the same library. I can see those custom properties in SB Explorer so I kno w they are being set properly.
Now when I receive the message in the function the ApplicationProperties are empty.
Can anyone help me figure out why the custom properties are not being populated when I receive the message when I know they are being set correctly from SB Explorer?
FYI, I set the properties like this when I send the message.
message.ApplicationProperties.Add("@message.event","eventName");
This is the method that I use to send the messages
public async Task SendMessage<T>(T messageObject)
{
ServiceBusMessage message = new ServiceBusMessage(JsonConvert.SerializeObject(messageObject));
message.ApplicationProperties.Add(MessageProperties.Event, "RackIntegration");
message.ApplicationProperties.Add(MessageProperties.Plant, "CNW");
try
{
await sender.SendMessageAsync(message);
}
finally
{
await sender.DisposeAsync();
await client.DisposeAsync();
}
}
Once the servicebus trigger received the message I try to get the custom properties like this
string prop1 = receivedMessage.ApplicationProperties[MessageProperties.Event].toString();
And as I show in the screen print above the ApplicationProperties collection is empty when the message is retrieved by the function trigger.
I wrote a small console app to receive the message manually using ServiceBusProcessor. When I do that the ApplicationProperties are correctly populated.
So it seems that it is an issue with the Function ServiceBus trigger...maybe?

