I've got an Azure function that currently consumes messages from an Azure Service Bus, does some transformation and posts a message to an Azure Event Hub. However, I also want to post a message to an Azure Service Bus, different from the one I'm consuming from. Can this be achieved by using multiple return values?
[FunctionName("IntegrationFunction")]
[return: EventHub("%Transactions:EVH:Transactions:Hub%", Connection = "Transactions:EVH:Transactions")]
public Transaction Run(
[ServiceBusTrigger(
"%Transactions:SB:Transactions:ReceiveTopic%",
"%Transactions:SB:Transactions:AnalyticsTopicSubscription%",
Connection = "Transactions:SB:Transactions")]
string mySbMsg,
ILogger log)
{
if (string.IsNullOrWhiteSpace(mySbMsg))
{
throw new ArgumentNullException(nameof(mySbMsg));
}
log.LogInformation($"Service bus topic trigger function processing message: {mySbMsg}");
var retailTransaction = JsonConvert.DeserializeObject<RetailTransaction>(
mySbMsg,
JsonSerialisationUtils.SerialiserSettings);
if (retailTransaction == null)
{
throw new JsonException("Deserialized transaction was null");
}
try
{
var transaction = retailTransaction.ToDto();
log.LogInformation($"Transaction {transaction.TransactionNumber} processed.");
return transaction;
}
catch (Exception e)
{
log.LogError(e, "Error mapping transaction.");
}
return null;
}
It is not feasible to use multiple return in azure function as mentioned in this github issue instead you can use
CloudQueueorIAsyncCollector<T>object..csproj-
Output-
1st Service Bus Topic-
I am sending message from this Service Bus.
Event Hub-
2nd Service Bus Queue-