【发布时间】:2018-06-16 04:40:17
【问题描述】:
我已经设置了一个 Azure 函数,我希望它异步运行,因为我希望我的队列中有成百上千/更多的消息将同时出队,所以我已经实现了它下面(也许有更好的方法)。还是我需要担心在函数中异步运行代码?
如果队列中的数千条消息一次全部出列,Azure 会同时处理数千个这样的函数吗?这个 Azure 函数article 说一次只能运行几百个
在哪里放置 try catch 语句的最佳位置?在围绕我的逻辑的异步调用内部还是在异步调用外部(如我的代码)?还是有关系?
public static class CancelEvent
{
[FunctionName("CancelEvent")]
public static async void RunAsync([ServiceBusTrigger("canceleventqueue", AccessRights.Manage, Connection = "service_bus_key")]string myQueueItem, TraceWriter log, ExecutionContext context)
{
try
{
await Task.Run(() => Processor.ProcessAsync());
}
catch(Exception ex)
{
}
}
}
public class Processor
{
public static void ProcessAsync()
{
// do the work
}
}
【问题讨论】:
标签: c# azure asynchronous exception-handling azure-functions