我正在使用带有T JSON可序列化类型的Output绑定。 我希望可以选择不创建消息就返回。 由于该选项不适用于T类型,因此我尝试将函数返回类型更改为字符串, 然后我将JsonConvert.SerializeObject(...)添加到了原始返回中。
现在,消息直接进入死信队列,错误为:“无效的messageId或内容类型”
是否可以将函数返回值设置为T,并且仍然可以选择不向队列发送消息?
为什么我收到无效的messageId错误?
[FunctionName("MyFunc")]
[return: ServiceBus("myqeueu", Connection = "ciServicebusConnectionString")]
public static string Run([EventGridTrigger] JObject message, ILogger logger,CancellationToken cancellationToken) {
_logger = logger;
var mediaServicesHelper = new MediaServicesHelper();
EventGridEvent eventGridEvent = GetEventGridEvent(_logger, message, cancellationToken);
if (!ValidateEventType(logger, eventGridEvent, AcceptedEvents))
{
// In this case, I don't want to write message to the queue
return null;
}
JObject eventDataObject = GetEventGridData(_logger, eventGridEvent);
if (eventDataObject == null)
{
return null;
}
var eventData = eventDataObject.ToObject<MediaJobStateChangeEventData>();
return JsonConvert.SerializeObject(RunMessage(eventGridEvent, eventData, mediaServicesHelper));
}