Jump Start ASP.NET Core Application on Nano Server
This post is provided by Senior App Dev Manager, Linkai Yu who shares some tips to speed up ASP.NET Core Application dev on Nano Server.
With the Nano server release from Windows 2016 Server, I’m excited to see the new application deployment practice to work with the thin and fast OS.
If you are new to ASP.NET Core application deployment on Nano server, I hope this blog will help you get up and running quickly while avoiding wasting time on the old documentation.
If you search “asp.net core app on nano server”, you will find some older documentation such as:
These documents are all based on the traditional architecture where you create a Nano OS image, configure it for ASP.Net Core and IIS, then boot up the OS and the app runs. The steps are long and are error prone.
There is a new approach and a better way to do this. If you search “visual studio 2017 docker tutorial”, you will find articles such as:
With the new Visual Studio support for containers, things become much easier. With Visual Studio 2017, if you install Docker for Windows on your development machine (currently only Windows 10 and Windows Server 2016 are supported) you can build an ASP.NET Core app and enable the Docker support in the project. When you build and run it in Docker, Docker will pull down the Nano server image that has ASP.Net Core on it to your local machine and run your app. Basically you don’t have to deal with OS anymore. If you have a regular ASP.NET application, you can do the same thing. The difference is that Visual Studio will configure the dockerfile to pull a Windows Core OS image that has ASP.NET and .NET framework installed.
To provide you with a simple intuitive guideline, there are the steps:
- Install Docker for Windows. In the Docker settings, select Windows Containers if you want to run Nano server.
- In Visual Studio 2017, create an Asp.Net Core web project, (either select Docker support when creating the project or Add Docker support after the project is created)
- Build and Run Docker (Docker replaces the Debug button in Visual Studio)
- You can also build the Release version and then you can run it outside the Visual Studio, in a regular CMD console (e.g. c:\>docker run myNetCoreApp)
Premier Support for Developers provides strategic technology guidance, critical support coverage, and a range of essential services to help teams optimize development lifecycles and improve software quality. Contact your Application Development Manager (ADM) or email us to learn more about what we can do for you.