.NET 7 comes to Azure Functions & Visual Studio 2022
We’re thrilled to announce that Azure Functions v4 now supports .NET 7 as runtime. Azure Functions joins Azure Web Apps who also announced .NET 7 support.
For those developers who are looking into building serverless functions in Azure with the latest innovation from .NET runtime, this makes it possible for all developers on the planet to focus on coding with .NET 7 new features, ready-to-code while on a large scale without worrying about the underlying infrastructure.
What’s new in .NET 7 with Azure Functions
You can now build your serverless applications with .NET 7 in Azure Functions using the .NET Isolated Worker model, which provides an isolation model that decouples your function process from the Azure Functions runtime, bringing the flexibility needed to target different versions of .NET, more efficiently manage dependencies and service registration.
The isolated worker model also allows you to use current .NET behaviors for dependency injection and incorporating middleware into your function app. Choose the isolated model if you’re upgrading from .NET 5 Azure functions v3. This feature is available for preview in all Windows & Linux-based plans in addition to premium plans.
How to try it out?
There’s no difference as you’re used to create an Azure function in .NET 7 runtime in an isolated process. We have core tools available to create a new Azure function in .NET 7 and support in Visual Studio 2022 17.4 Preview 1.
Azure Functions Core tools
To get started, we could leverage Azure Functions Core Tools to scaffold an isolated project folder structure as follows:
func init --worker-runtime dotnet-isolated --target-framework net7.0
Then use func new command to scaffold an HTTP trigger function. The following is an example command to create a function called
DotNet7function using an HTTP trigger:
func new --name DotNet7Function --template "HTTP trigger"
And then you can use the func start command to test out this function.
Visual Studio 2022
Visual Studio makes it easier for all developers to build serverless applications with Azure functions by streamlining the function creation workflow, with rich local development and debugging experience, and quickly publishing your .NET applications to Microsoft Azure.
Update your Visual Studio 2022 to 17.4 Preview 1.0
Follow the Visual Studio update process on the official documentation, and ensure you’re compliant with all the prerequisites before you update. Note that, you need to set your update channel to Preview in your More -> Update settings from Visual Studio Installer as the following:
Make sure you have set the Modify -> Individual Component to include .NET 7 SDK ( Preview ), and .NET 7.0 Runtime ( Preview ):
Create your Azure Functions
When you create a new Azure Function in Visual Studio where you’ll find a new option for .NET 7 Isolated:
Deploy your Azure Functions
Visual Studio provides a simple way to publish your application to Microsoft Azure. You can deploy your serverless application to Azure by simply right-clicking on your functions application in Visual Studio and then Publish. Select your publish target and publish your functions to Azure:
We’re looking forward to hearing your feedback and your use cases, please feel free to share them on announcement related discussions. Also, if you discover potential issues, please record them on the Azure Functions .NET language worker GitHub repository.
Coming up, we’re also closely collaborating with the community and ensuring your voices are heard, check out our public-facing product roadmap from: http://aka.ms/af-dotnet-roadmap.
Start to build your serverless applications with .NET 7, check out the official documentation:
- Getting started with Azure functions in an isolated process
- Create your first .NET 7 functions with Azure Core tools
If you are interested in learning more about Azure Functions v4, be sure to watch the recent On .NET episode with Matthew Henderson & Fabio Cavalcante from the Azure Function team.
We’re excited about the road ahead with the continued innovation from .NET on Azure functions.