Async programming and Azure functions

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Async programming and Azure functions

Message par Clippy »

Async programming and Azure functions
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: Async programming and Azure functions

Message par Clippy »

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 »