It is generally recommended to use ConfigureAwait(false)
when awaiting async calls when context is not required. Just wondering is there any benefit of using ConfigureAwait(false)
in Azure Functions.
Do Azure Function threads have non-null SynchronizationContext
as such it would make beneficial to use ConfigureAwait(false)
to avoid unnecessarily capturing it and rescheduling the await continuation back on the captured SynchronizationContext
?
It is a bit of a churn to add ConfigureAwait(false)
at the end of every async call so prefer to avoid it for the code that runs in Azure Functions if there is no perf/or any other related gain.
Looking at the azure function host code: https://github.com/Azure/azure-functions-host/blob/918b057707acfb842659c9dad3cef0193fae1330/src/WebJobs.Script.WebHost/WebScriptHostManager.cs#L181
it seems like azure function host attempts to strip out the ASP.NET SynchronizationContext before calling the azure function.
ConfigureAwait(false)
for server-side code? As I remember, it's quite the opposite. – Mixup