Async programming and Azure functions

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Async programming and Azure functions

Message par ForumBot »

Async programming and Azure functions
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Async programming and Azure functions

Message par ForumBot »

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.
Répondre

Revenir à « Azure Infrastructure »