Sunday, November 14, 2021

.NET 6 and Azure Functions

Last week during the .NET Conf 2021, a thrilling announcement was made related to Azure Functions, that is the General Availability (GA) of Azure Functions Runtime 4.0. With that we can now target .NET 6 for .NET Azure Functions that were written following both the In-Process and Isolated (Out-of-process) models.

If you are wondering what are In-Process and Isolated (Out-of-process) models in .NET Azure Functions, let me give a quick overview.

Isolated (Out-of-process) is a relatively new approach for writing .NET Azure Functions. But it has been the way for writing Azure Functions with other programming languages (Python, JavaScript, Java etc). It got introduced back in 2020 with .NET 5. Up to that time, we could only create .NET Functions following the In-Process model. With the In-Process model, our functions apps were class libraries and had a tight coupling to the functions host.  Because of that, .NET functions were required to be on the same version of .NET as the Azure Functions Runtime. And that's why we couldn't target .NET 5 for In-Process Azure Functions before. 

To get out of this constraint, Microsoft has introduced a new programming model which is Isolated (Out-of-process), and there, the functions apps are console applications (not class libraries) and they are running in it's own host (hence the name). So now we can target different .NET versions for our functions that were not supported by the Functions runtime. There are feature and functionality differences between In-Process and Isolated (Out-of-process) models. For example, Durable Functions are not supported (as of today, but it's going to be coming in 2022) with Isolated (Out-of-process) model. But it follows the same programming model as in ASP.NET Core, so we have more control over the things such as being able to write our own Middleware which isn't possible with In-Process model.

So now we know what's In-Process and Isolated (Out-of-process) models in .NET Azure Functions. So how is the roadmap of .NET Azure Functions going to be like?

Azure Functions .NET Roadmap
As shown in the above, the Isolated (Out-of-process) model is going to be the way forward. As of today, Azure Functions Runtime 4.0 is the recommended runtime version for functions in all languages. If you have .NET Azure Functions written following In-Process model and using features that aren't supported in Isolated (Out-of-process) model (Durable Functions etc), you can upgrade your functions to be on Azure Functions Runtime 4.0 and target .NET 6 still following the same programming model. And if all your features have support in Isolated (Out-of-process) model, you should update the programming model to Isolated (Out-of-process) model.

With Visual Studio 2022, you have now all these nice options to create your.NET Function App, do give it a try.

.NET Function Apps
More read,
   Announcement: Azure Functions 4.0 and .NET 6 support are now generally available
   Guide for running C# Azure Functions in an isolated process
   Azure Functions runtime versions overview

Happy Coding.

Regards,
Jaliya

No comments:

Post a Comment