Async programming and Azure functions

前端 未结 1 1638
臣服心动
臣服心动 2021-02-02 07:30

In the Azure functions \"Performance considerations\" part, Functions Best Practices, under \"Use async code but avoid blocking calls\", async programming is the su

相关标签:
1条回答
  • 2021-02-02 07:50

    You can make the function async:

    public static async Task Run(
        [ServiceBusTrigger("topicname", "subname", AccessRights.Manage, Connection = "TopicConnection")]string message,
        TraceWriter log)
    {
        try
        {
            log.Info($"C# ServiceBus topic trigger function processed message: {message}");
            await PushToDb(message, log);
        }
        catch(Exception ex)
        {
            log.Info($"Exception found {ex.Message}");
        }
    }
    

    The Functions runtime allows you to make your function async and return a Task.

    In this case we can just await the call so we can handle exceptions normally.

    0 讨论(0)
提交回复
热议问题