Das ist mein Code – das ist das Ausgabebindungsmodell des Event Hub:
Code: Select all
using System.Diagnostics.CodeAnalysis;
using Azure.Messaging.EventHubs;
using Microsoft.Azure.Functions.Worker;
public class RetryFailedEventHubOutputBindings
{
public RetryFailedEventHubOutputBindings()
{
OutEventHub1 = [];
OutEventHub2 = [];
}
[EventHubOutput("OutEventHub1", Connection = "EventHubConnection")]
public EventData[] OutEventHub1 { get; set; }
[EventHubOutput("OutEventHub2", Connection = "EventHubConnection")]
public EventData[] OutEventHub2 { get; set; }
}
Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Azure.Messaging.EventHubs;
using Microsoft.Azure.Functions.Worker;
using Newtonsoft.Json;
public class RetryFailedFunction
{
private static readonly SemaphoreSlim Semaphore = new(1, 1);
private readonly IFailedMessageService _failedMessageService;
private readonly IAppLogger _logger;
public RetryFailedFunction(IFailedMessageService failedMessageService, IAppLogger logger)
{
_failedMessageService = failedMessageService;
_logger = logger;
}
[Function(nameof(RetryFailedFunction))]
public async Task RunAsync([TimerTrigger("%ScheduleTriggerTime%")] TimerInfo myTimer)
{
var outputBindings = new RetryFailedEventHubOutputBindings();
outputBindings.EventHub2.Append(new EventData(Encoding.UTF8.GetBytes("{\"ErrorId\": 10}")));
return outputBindings;
}
}
Code: Select all
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Text;
using System.Threading.Tasks;
using Azure.Messaging.EventHubs;
using Microsoft.Azure.Functions.Worker;
using Newtonsoft.Json;
public class ReceiverFunction
{
private readonly IErrorRepository _errRepo;
private readonly IRawEventHandler _rawEventHandler;
private readonly IProductValidationHelper _productValidationHelper;
private readonly IAppLogger _logger;
private readonly IUpdateRetryStatusService _updateRetryStatusService;
public ReceiverFunction(IErrorRepository errRepo, IUpdateRetryStatusService updateRetryStatusService, IRawEventHandler rawEventHandler, IProductValidationHelper productValidationHelper, IAppLogger logger)
{
_errRepo = errRepo;
_updateRetryStatusService = updateRetryStatusService;
_rawEventHandler = rawEventHandler;
_productValidationHelper = productValidationHelper;
_logger = logger;
}
[Function(nameof(ReceiverFunction))]
[EventHubOutput("SomeEventHub", Connection = "EventHubConnection_1")]
public async Task RunAsync([EventHubTrigger("EventHub2", Connection = "EventHubConnection", ConsumerGroup = "%EventHubConsumerGroup%")] EventData[] inputEvents)
{
var outputEvents = new List();
foreach (var eventData in inputEvents)
{
// Event processing logic
}
}
}
Dies sind Änderungen in meinem Paket der Funktions-App nach der Migration:

Wie im ersten Bild gezeigt, erhalte ich nicht die erwarteten Daten im Receiver Event Hub, sondern diese Ich zeige nur den Datentyp.
Wenn ich den Datentyp in einen anderen Typ wie string[] oder string oder einen anderen starken Typ ändere, funktioniert es auch ohne irgendwelche Probleme, das Problem betrifft auch nur EventData Es handelt sich um ein EventData-Array oder einfach nur um EventData.
Und EventData[] funktionierte vor der Migration auch im alten Code.
Können Sie mir bitte bei diesem Problem helfen? Gibt es eine Einschränkung mit der isolierten Azure-Funktion von .NET 8 für EventData?, oder mache ich hier etwas falsch?