Running .NET 5 (preview) on App Service

3 minute read • By Jeff Martinez • April 24, 2020

.NET 5 is the latest version to expand the capabilities of .NET by taking the best of Core, Framework, Xamarin, and Mono to create a unified platform for improving developer scenarios. .NET 5 is currently in preview and available for use in existing or new applications. Find more information on the release and how to upgrade an existing project here.

To get started with .NET 5 on App Service you can use one of two deployment methods. A Self-Contained deployment will allow you to deploy your app on machines that don’t have the runtime installed. You can also deploy your application with a more portable solution using a Container which will package your app and dependencies to run on App Service.

Local Setup

In order to setup .NET 5 in your application you need to first install the .NET 5.0 SDK. There are a number of preview versions of .NET 5 SDK’s available. We recommend using the latest SDK v5.0.0-rc.1, a feature complete Release Candidate SDK. If you’re on Windows using Visual Studio, you will also need to download the latest Visual Studio Preview version here.

Self-Contained Deployment

A Self-Contained deployment enables you to run .NET 5 because it doesn’t rely on the presence of shared components on the target system and all components including Core libraries and runtime are with the application and isolated from other apps. This way you have sole control of which version your application is running. Self-contained deployments are supported for both Windows and Linux apps. Note that with self-contained applications you should be aware of large deployments and managing updates as this will take up more hard drive space and cause you to be responsible for supplying updated versions of your app with new security patches.

  1. To complete a self-contained deployment in .NET you would first create your project as usual then choose ASP.NET Core 5.0 for your apps version after selecting your application template. Select Create and modify your application as needed.

    dotnet5

  2. To publish, simply Right-Click your project and select publish. In the latest version of Visual Studio you can choose where your target publish is from a new menu.

    dotnet5

  3. Then select Azure App Service (Windows) or Azure App Service (Linux) depending on your preference on the following screen.

    dotnet5

  4. Next, choose a previously created App Service or create one from Visual Studio and fill out the required information as you normally would when publishing. When you reach the publish screen click the pencil icon to edit your Deployment Mode for publishing your application.

    dotnet5

  5. Next, Choose the Deployment Mode option and make sure Self-Contained is chosen.

    dotnet5

After you select the Self-Contained option your Target Runtime will auto-populate to linux-x64 or win-x86 depending on your operating system selection. Save your new settings and click Publish on the preceding screen to publish to App Service and launch your application using .NET 5. More information on self-contained deployment can be found here.

Container Deployment

The other option for running your .NET 5 application is to deploy a Docker container to App Service on Linux or Windows (Premium SKU only). When deploying a container, you are packaging the application and its dependencies into a Linux or Windows based image to run on the App Service platform. This enables your application to be more portable in nature as it is not reliant on the host operating system and has the runtime and SDK added into the image.

Once you have your application setup for .NET 5, the steps to deploy a containerized application would be the same as any other container deployment. Right-click your project, Add -> Docker Support . Your .NET 5 project will have a new Dockerfile added with the .NET 5.0 base image and SDK ready for you to publish.

dotnet5

After you have added Docker support, you will publish it to a registry, and create your App Service as usual. See our documentation for more detail on deploying a containerized application.