无法调试 Azure 事件中心函数



我在VS 2019中的EventHub事件触发的Azure函数上加载断点时遇到问题,但当我去调试时,从未加载断点。它卡在的"没有加载符号…"位置

这是我的功能:

[FunctionName("Function1")]
public static async Task Run(EventData[] events, ILogger log)
{
var exceptions = new List<Exception>();
foreach (EventData eventData in events)
{
try
{
string messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count);
// Replace these two lines with your processing logic.
log.LogInformation($"C# Event Hub trigger function processed a message: {messageBody}");
await Task.Yield();
}
catch (Exception e)
{
// We need to keep processing the rest of the batch - capture this exception and continue.
// Also, consider capturing details of the message that failed processing so it can be processed again later.
exceptions.Add(e);
}
}
// Once processing of the batch is complete, if any messages in the batch failed processing throw an exception so that there is a record of the failure.
if (exceptions.Count > 1)
throw new AggregateException(exceptions);
if (exceptions.Count == 1)
throw exceptions.Single();
}

我正试图通过在方法的开头放置断点来调试Run()函数

这似乎是一个编译问题。试着重建它,看看它是否有效。此外,您的函数中似乎缺少触发器/连接字符串信息:

[EventHubTrigger("samples-workitems", Connection = "EventHubConnectionAppSetting")]

更多信息:

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs-trigger?tabs=csharp

最新更新