Enterprise Application Modernization using Windows Containers

Developer Support

App Dev Manager Farah Deendar explores first steps of application modernization through simple containerization.


As an Application Development Manager, I often have conversations with my enterprise customers around application modernization, its synonymy with containers and microservices and what is the best way to modernize line of business applications. Many enterprise organizations today have numerous desktop applications that are CRUD based and call for modernization without necessarily needing to re-architect these LOB legacy apps. Web Apps on traditional .NET framework, ASP.NET web forms, MVC or WCF apps are common examples. If you have an existing .NET enterprise application that could use CI/CD but not necessarily any immediate rearchitecting efforts containerizing your application is the way to go. Although the role of Domain Design Modeling and use of Microservices is vital to modernizing Enterprise Architecture and applications, it does not always make business sense to rearchitect a legacy application.

The focus of this blog is to help developers in the enterprise to containerize existing .NET Framework applications/services that currently need to run on Windows. I will be using Windows Containers for the rest of this blog. The windows containers can be run at scale with Azure containers as an option with many benefits. If you don’t want to move to the cloud, you can apply these approaches on-premises, too.

Steps to containerize a windows Desktop application:

  1. Pre-requisites for a working Environment:
    1. Windows 10 Enterprise/Pro with Hyper-V enabled
    2. Docker for Windows. The full list of pre-req’s is available here.
    3. Command Shell or PowerShell for windows
    4. Visual Studio 2017, ASP.NET/MVC/WCF app Note: To get things working via Windows, select the option “Switch to Windows containers” in the Docker tray icon. See below: A screenshot of a cell phone Description automatically generated Note: Docker for Windows after install defaults to Linux containers.
  2. Asp.net Desktop application: For the purposes of this blog, the containerization sample ASP.NET application used is available here. You can use your existing .net app in place of this sample and follow the steps provided in the sample and/or below:
  3. Containerize your application.
    1. Navigate to your local project directory and create the docker file. The key to containerizing your application is building your Dockerfile. A docker file is a text document that contains all the commands to build your container image. More details on Dockerfile are available here. Below PowerShell command you will use to create the dockerfile in your project root folder: New-Item C:/YourProjLocation/Dockerfile -type file
    2. Next you will add logic to your Dockerfile that declares which base image you will use to build your container. See writing to your Dockerfile as an example or below PowerShell Command: FROM microsoft/aspnetcore-build:1.1 AS build-env WORKDIR /app COPY *.csproj ./ RUN dotnet restore COPY . ./ RUN dotnet publish -c Release -o out FROM microsoft/aspnetcore:1.1 WORKDIR /app COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "MvcMovie.dll"]
    3. Now you will tell docker to build your app and run the container. PowerShell command: docker build -t myapp docker run -d -p 5000:80 --name myapp myasp Note: Your powershell console’s current working directory needs to be pointing to where your dockerfile resides.
    4. Get the IP address of your running container using the command below PowerShell Command docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" myapp
    5. Copy the IP address to your local web browser. You have successfully containerized your ASP.NET application!

Resources to help Scale your containers on premises:

Docker hosts with Windows Containers on Windows Server 2016. VMs/Servers can be on-premises. For your orchestration needs Azure Service Fabric can be on-premises as well as Kubernetes can be on-premises.

Resources to help Scale and run your Containers in the Cloud:

Containerizing monolithic applications in Azure

https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/architect-microservice-container-applications/containerize-monolithic-applications

Azure Service Fabric

https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-containers-overview

Container Orchestration in the Cloud

Container orchestrators are assigned a pool of servers (VMs or bare metal servers), commonly called a “cluster,” and “schedule” deployment of containers onto those servers. Some orchestrators go further and configure networking between containers on different servers, while some include load balancing, container name resolution, rolling updates and more. Some are extensible and enable application frameworks to bring these additional capabilities. While a deeper discussion on orchestration solutions might require a whole other post on its own, here’s a quick outline a few of the technologies, all supported on top of Azure:

Premier Support for Developers can help with your organizational readiness and deployment of Enterprise Application Modernization. For more information go here or please contact Farah Deendar.

0 comments

Discussion is closed.

Feedback usabilla icon