Using Chef Habitat to Migrate Legacy Windows Applications - Perficient Blogs
Blog
  • Topics
  • Industries
  • Partners

Explore

Topics

Industries

Partners

Using Chef Habitat to Migrate Legacy Windows Applications

Overview

In this bog post we will discuss Using Chef Habitat to Migrate Legacy Windows Applications to a Modern Secure Platform. With support ending for Windows Server 2008 and Microsoft SQL Server 2008, legacy Windows applications will need to be migrated to newer secure and supportable modern platforms. For instance, Windows Server 2016 and 2019 along with Microsoft SQL Server 2017 and later. In this blog post, the third in our series on Chef Habitat, we will migrate a legacy ASP.NET 2.0 application from Windows Server 2008 and Microsoft SQL Server 2005 to a Windows Server 2016 physical or virtual machine and a Docker container with Windows Server 2016 Core. Windows Server 2016 Core is a striped down version of Windows Server without a GUI and is managed as you would Linux, from the command line. Since there is no GUI, the attack surface is reduced and the OS image is significantly smaller. Only what needs to be loaded for the application will be installed. Chef has a Github repository with a legacy ASP.NET 2.0 Application from the Codeplex Archive that we will be installing. This will show how Legacy ASP.NET 2.0 applications can be migrated to modern and secure platforms.

Prerequisites

See the previous blog post under Prerequisites and Workstation Setup for installing the required tools and configuring Chef Habitat.

VMs need to be running Windows Server 2016 with a minimum of 4GB of RAM. Containers need 2GB of RAM for each container.

Note: This application currently only runs on a Windows Server running on a physical/virtual hardware, or in a container but not directly on Windows 10. For Docker on Windows, you must be running in Windows container mode. AWS or Azure images will need to have Docker preinstalled, and at least 50GB of disk space.

Common Steps for Windows Server and Containers

Now the code from the Github repository needs to be downloaded. This needs to be on the root of the C: drive. The MS SQL Server installation can fail if the path is to long. Entering into a local studio at c:\users\administrators\sqlwebadmin will result in a much longer install path than entering from c:\sqlwebadmin. Clone the repository and cd into the top level directory:

cd c:\
git clone https://github.com/habitat-sh/sqlwebadmin
cd sqlwebadmin

A local default origin should have been setup from the Prerequisites and Workstation Setup section in the previous blog post.

The INSTALL_HOOK now needs to be enable. See this blog post for more information.

$env:HAB_FEAT_INSTALL_HOOK=$true

This plan takes advantage of several dependencies that use this feature to run an install hook when the dependency is installed for things like enabling windows features and registering a COM component.

Installing on a Windows Server 2016 (Physical or Virtual)

Enter a local Habitat Studio and load core/sqlserver2005:

hab studio enter
hab svc load core/sqlserver2005

This will take several minutes to load since it is downloading and installing the .Net 2.0 runtime and installing SQL Server 2005, while its loading, build this plan:

build

Now we need to wait for SQL Server’s post-run hook to complete. View the Supervisor output with Get-SupervisorLog and wait for the message:

sqlserver2005.default hook[post-run]:(HK): 1> 2> 3> 4> 5> 6> Application user setup complete

Now load <your_origin>/sqlwebadmin:

hab svc load <your_origin>/sqlwebadmin --bind database:sqlserver2005.default

In the Supervisor log wait for:

sqlwebadmin.default(O): sqlwebadmin is running

The website should now be accessible. Browse to http://localhost:8099/databases.aspx.

Exporting to a Windows Server 2016 Docker Container

Export the core/sqlserver2005 package to a docker image:

$env:HAB_SQLSERVER2005="{\`"svc_account\`":\`"NT AUTHORITY\\SYSTEM\`"}"
hab pkg export docker --memory 2gb core/sqlserver2005

The first line above will make sure that the SQL Server install sets the svc_account to the SYSTEM account instead of the default NETWORK SERVICE account which is advisable in a container environment.

Build our sqlwebadmin package (make sure you are still in c:\sqlwebadmin):

hab pkg build .

Export our sqlwebadmin hart to a docker image:

hab pkg export docker --memory 2gb <path to HART file>

Now lets bring these two containers together into a Habitat supervisor ring:

$sql = docker run -d --env HAB_LICENSE=accept-no-persist --memory 2gb core/sqlserver2005
$ip = docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $sql
docker run -it --env HAB_LICENSE=accept-no-persist <your_origin>/sqlwebadmin --bind database:sqlserver2005.default --peer $ip

Alternatively you can use Docker Compose along with the provided docker-compose.yml to bring up the containers. Update the docker-compose.yml file with your origin and the environment variables below for each container:

version: '2.2'
services:
  sqlserver2005:
    image: core/sqlserver2005
    environment:
      - HAB_LICENSE=accept
  sqlwebadmin:
    image: <your_origin>/sqlwebadmin
    environment:
      - HAB_LICENSE=accept
    ports:
      - 8099:8099
    links:
      - sqlserver2005
    depends_on:
      - sqlserver2005
    command: --peer sqlserver2005 --bind database:sqlserver2005.default

networks:
  default:
    external:
      name: nat
docker-compose up

Grab the IP address of the sqlwebadmin container:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aql)

Browsing to http://<CONTAINER_IP>:8099/databases.aspx should bring up the application.

Perficient can help!

In this blog post we discussed the steps of Using Chef Habitat to Migrate Legacy Windows Applications to a Modern Secure Platform using Chef Habitat. With Windows and SQL Server end-of-support happening beginning this year, now is the time to begin migrating those legacy applications with Habitat. This approach eliminates your dependencies on these legacy operating systems and helps you avoid costly support contracts.  We can also help you modernize your application development processes at the core, using an OS independent approach that makes your business more innovative and resilient for the future.  Let us know if we can help.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up