I'm publishing an object to an Azure Event Hub using output bindings like so.
[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)
{
var retailTransaction = JsonConvert.DeserializeObject<RetailTransaction>(
mySbMsg,
JsonSerialisationUtils.SerialiserSettings);
try
{
var transaction = retailTransaction.ToDto();
log.LogInformation($"Transaction {transaction.TransactionNumber} processed.");
return transaction;
}
catch (Exception e)
{
log.LogError(e, "Error mapping transaction.");
}
return null;
}
Is there any way to publish it to a specific partition e.g. transaction.StoreCode?
You can pass the partition key value while publishing the events to EventHub using
IAsyncCollector<EventData>. Refer the MSDoc and github issue for more details..csproj-
I am able to publish the event.