Azure Functions 3.0: What’s New for .NET Developers

Azure Functions 3.0 is now generally available, bringing .NET Core 3.1 support and significant improvements. Here’s what developers need to know.

Cloud computing and serverless architecture
Photo by NASA on Unsplash

Key Improvements

  • .NET Core 3.1 Support: Run your functions on the LTS version
  • Dependency Injection: First-class DI in the functions runtime
  • Improved Cold Start: Faster startup times in consumption plan
  • HTTP Triggered Functions: ASP.NET Core integration model

Dependency Injection Example

// Startup.cs
public class Startup : FunctionsStartup
{
    public override void Configure(IFunctionsHostBuilder builder)
    {
        builder.Services.AddScoped<IMyService, MyService>();
        builder.Services.AddHttpClient();
    }
}

// Function with DI
public class MyFunction
{
    private readonly IMyService _service;
    
    public MyFunction(IMyService service) => _service = service;

    [FunctionName("ProcessData")]
    public async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequest req)
    {
        var result = await _service.ProcessAsync();
        return new OkObjectResult(result);
    }
}

Migration from 2.x

The migration is straightforward:

  1. Update to .NET Core 3.1
  2. Change target framework to netcoreapp3.1
  3. Update NuGet packages to 3.x versions
  4. Review breaking changes in Newtonsoft.Json handling

References


Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.