Это мой код — это модель привязки вывода концентратора событий:
Код: Выделить всё
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; }
}
Код: Выделить всё
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;
}
}
Код: Выделить всё
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
}
}
}
Это изменения в моем пакете функционального приложения после миграции:

Как показано на первом изображении, я не получаю ожидаемые данные в концентраторе событий приемника, вместо этого они просто показываю тип данных.
Если я изменю тип данных на любой другой тип, например string[] или string или любой другой строгий тип, то он будет работать без любые проблемы, проблема только для EventData, либо это массив EventData или просто EventData.
И EventData[] тоже работал в старом коде до миграции.
Можете ли вы помочь мне с этой проблемой, есть ли какие-либо ограничения на изолированную функцию Azure .NET 8 для EventData, или я делаю что-то не так?
Подробнее здесь: https://stackoverflow.com/questions/793 ... n-app-from
Мобильная версия