September 9th, 2022

.NET 7 comes to Azure Functions & Visual Studio 2022

Melony Qin
Product Manager

NOTE: This blog was originally posted to the Apps on Azure blog for the initial preview and Visual Studio 2022 support.

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.

func start

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:

Update Settings in Visual Studio

Make sure you have set the Modify -> Individual Component to include .NET 7 SDK ( Preview ), and .NET 7.0 Runtime ( Preview ):

Install .NET 7 Preview in Visual Studio

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:

Create a .NET 7 Function

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:

Deploy an Azure Function

Next steps

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:

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.

Author

Melony Qin
Product Manager

I'm a product Manager in Microsoft Developer Experience Team and a published author of 3 books over the last 5 years, including the Kubernetes workshop, Certified Kubernetes Administrator (CKA) Exam Guide, and Microsoft Azure infrastructure published with Packt Publishing. If you're passionate about cloud-native technologies, join me on cloud-melon.com and CloudMelon Vis on Youtube. I've been striving to provide best-in-class product experiences to help customers and partners worldwide to ...

More about author

5 comments

Discussion is closed. Login to edit/delete existing comments.

  • ks-beataim

    There’s no NET 7 SDK ( Preview ) in VS installer (only runtime). Thus no NET 7 function to select when creating a project…

  • Tony Henrique · Edited

    I am creating a new Azure Function on the Azure Portal, region: Brazil South, https://portal.azure.com/#create/Microsoft.FunctionApp ,
    select runtime stack .NET, but only version 6 and 3.1 are listed, no 7.

    • Melony QinMicrosoft employee Author

      Hi Tony, For the portal experience will be coming soon, stay tuned! In the meantime, you can use Visual Studio / VS Code to publish to your existing Functions App, which will update the runtime setting automatically!

  • David Petric

    Hello,

    Really interested about more information regarding integration testing and WebApplicationFactory, TestServer alternatives for in memory testing from Asp.Net Core, as we are trying and use Azure Functions we use the in-process model.. for APIs. I managed to setup my own startup classes and setup a in memory database, but couldn't find a nice way to setup a HttpClient in memory, as solution offered for Asp.Net core.

    Thanks!

    Read more
    • Melony QinMicrosoft employee Author

      Thanks David, great feedback ! let me take this back to the team.