octocat.dev.

A Developer's blog.About

Deploying .NET 5 app on Azure App service

Shubhan Chemburkar
Shubhan Chemburkar
This post is cross post from archived blog at worldwidecode.wordpress.com

2022 Update: Although this post specifies .NET 5, its applicable for all .NET versions going forward

Azure App service now supports .NET 5 apps from Day 0. Read the announcement here. Congratulations to the team!

Byron Tardif @bktv99
A small step for @azure #appservice, one giant leap for #devkind. Announcing #dotnet5 support on Azure App Service. https://t.co/LEx74Z8Wjx
cc: @coolcsh @shanselman @scottgu
Source: Twitter

In this post, I'll walk you through the changes needed to support .NET 5 on Azure App Service using Azure DevOps.

  • Upgrade your app to .NET 5

    Usually this means changing the target framework to net5. Follow the migration guide here.

    Once you have your app working on your dev box, the next step is deployment.

In Azure portal,

  • Change the Stack Settings to .NET 5

    Assuming you were using .NET Core 3.1 earlier, change the selections to .NET 5.
    Important, first change the Stack option from .NET Core to .NET. The you will see the rest of the options for .NET 5.

In Azure DevOps,

  • Include .NET 5 SDK using the Use .NET Core step.

    This is required as the default agent image (windows-2019 in my case) does not yet include .NET 5 by default.

    To do this, go to your build Pipeline and add Use .NET Core step with version 5.x

  • Update the Deploy to Azure step

    Next you need to update the deploy step within Release job to use .NET 5.

    To do this, go to the Release node and update the Runtime Stack to DOTNETCORE|5.0.

If you set this incorrectly, after deployment it could happen that the Minor version is blank or empty. In that case check the Runtime Stack value again. If it re-occurs try to set it again manually to .NET 5 via the Azure Portal.

  • Now trigger a build, Azure DevOps will build the app using .NET 5 and then deploy it to Azure App Service.

Happy .NET 5 Deployments.

The source code for this blog is available on GitHub.