Page 32 - MSDN Magazine, April 2017
P. 32

CONTAINERS
Modernizing Traditional
.NET Apps with Docker
Elton Stoneman
The Microsoft .NET Framework has been a successful application platform for 15 years, with countless business-critical apps running on older versions of the Framework and older versions of Windows Server. These traditional apps still offer great business value, but they’re likely to be difficult to maintain, upgrade, extend and manage. Equally, they may not justify the investment needed for a full rewrite. With Docker, a platform for running applications in lightweight containers, and Windows Server 2016, you can give traditional apps a new lease on life—adding features, increasing security and performance, and moving toward continuous deployment—without a lengthy and expensive rebuild project.
In this article I’ll take a monolithic ASP.NET WebForms app that connects to a SQL Server database, and modernize it by taking advantage of the Docker platform. I’ll start by moving the whole app as is to Docker, without any code changes, and run the Web site and database in lightweight containers. Then I’ll show a feature- driven approach to extending the app, improving performance and giving users self-service analytics. With the Docker platform you’ll see how to iterate with new versions of the app, upgrade the components quickly and safely, and deploy the complete solution to Microsoft Azure.
Where Docker Fits in .NET Solutions
Docker is for server applications—Web sites, APIs, messaging solutions and other components that run in the background. You can’t run desktop apps in Docker because there’s no UI integration between the Docker platform and the Windows host. That rules out running Windows Forms or Windows Presentation Foundation (WPF) apps in containers (although you could use Docker to package and distribute those desktop apps), but Windows Com- munication Foundation (WCF), .NET console apps and all flavors of ASP.NET are great candidates.
To package an application to run in Docker, you write a small script called a Dockerfile that automates all the steps for deploying the app. Typically this includes Windows PowerShell commands for configuration and instructions to copy application content and set upanydependencies.Youcanunzipcompressedarchivesorinstall
This article discusses:
• Migrating .NET apps to containers
• Pulling dependencies from Docker Hub
• Breaking a monolithic application into smaller services
• Adding self-service analytics
• Running Dockerized solutions on Microsoft Azure
Technologies discussed:
Microsoft .NET Framework, Windows Server 2016, Docker, SQL Server, Elasticsearch, Kibana
Code download available at:
msdn.com/magazine/0417magcode
20 msdn magazine















































































   30   31   32   33   34