DEV Community

Cover image for .NET 5: Deploying web apps with Azure App Service
Daniel Gomez
Daniel Gomez

Posted on

.NET 5: Deploying web apps with Azure App Service

The innovation behind .NET is to integrate all Microsoft development tools: libraries, languages, technologies, and purposes under the same framework, which are useful to the developer or company that needs it.

In this sense, .NET introduces a unified platform in its ecosystem to support the construction of literally anything from desktop applications to video games, or web or mobile applications, there are really many things we can do.

Recently, in the .NET Conf 2020, the .NET version 5.0 has been officially released. .NET 5 is committed to a big change in relation to the concept of development, since all kinds of applications, whether desktop, console, web, or mobile, will be made with a single cross-platform framework and with great power. This will allow you to have a unique .NET runtime that can be used anywhere and for any type of development or device.

Now, one of the things that many wonders, when a new version of .NET is released, is about how we can deploy applications in the cloud with this new version, in this case, applications with .NET 5. Well, in the case of Azure, Microsoft has made it possible for applications developed with .NET 5 to be deployed from day zero thanks to its new feature Early Access Runtime, that will enable not only .NET 5 applications but each later version of .NET from now on.

All right, given this contextualization about the new version of .NET, let's look in a few steps at an example of how to deploy an application developed on .NET 5 to Azure App Service.

.NET 5 SDK

The first thing we'll need is to have the .NET 5 SDK installed.

Download link: https://dotnet.microsoft.com/download.

Project with ASP.NET 5

With the .NET SDK 5, we now need to target the project we want to deploy to Azure, for this case, let's create a new one to exemplify.

In this case with .NET 5:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

</Project>
Enter fullscreen mode Exit fullscreen mode

Azure App Service

To deploy our project to an App Service resource, we have two considerations that can be taken into account to specify that the framework and version of our application correspond to .NET 5.

Initially, the first way to specify the framework and version is when creating the App Service resource in the 'Runtime stack option in the Instance Details section:

The second way is when we already have the resource created, in case we want to switch from .NET Core 3.1 to .NET 5 for example. For this case, we will have to go to the App Service resource in question to the Configuration option and the General settings tab, here we must select the .NET stack with its .NET version 5.

With these specifications, we'll be ready to deploy our application with .NET 5 to Azure.

Publishing from Visual Studio 2019

For this example, we'll deploy our web application from Visual Studio 2019. To do this, you only have to right-click on the main project and select Publish.

Next, we'll need to specify our Azure App Service resource and finally, we'll be able to publish our app.

By the end of this process, our app will already be published to Azure:

What's next?

With these simple steps, we've seen how to deploy a web application developed on the new version of .NET 5. Surely in the coming days, we will see more use cases for the development of multipurpose cross-platform applications. In the meantime, here are some additional materials to expand our knowledge of .NET:

Thank you for reading.

If you have any questions or ideas that you need to discuss, it will be nice to be able to collaborate and together exchange knowledge with each other.

¡See you on Twitter! :)

Top comments (0)