;
January 7, 2020 Imran Arshad

Containerise and Migrate Legacy Classic ASP to Azure App Service

Legacy apps are sometimes very hard to modernise or are not worth modernising. You just want them working in their current state with minimal overhead.

Download source code here

Legacy apps are sometimes very hard to modernise or are not worth modernising. You just want them working in their current state with minimal overhead. Using Docker to migrate the legacy application to Azure App Service gives you many benefits. It improves SLA and scalability, removes the need for OS management/patching and ultimately extends the shelf life. I recently migrated an on-prem legacy classic ASP application by containerising and then hosting it to Azure App Service and would like to share the experience and challenges.

Prerequisites

Migrating the ASP Classic may not be straight forward in some cases and may require code changes. Application evaluation is required to check which parts can be migrated and the other parts that need to be rewritten. E.g. Azure App Service does not allow the registration of COM/COM+ components on the platform. If your application makes use of any COM components, these would need to be rewritten in managed code. If you are using Windows Authentication you may need to replace that with Azure AD and would require additional code and potential application logic changes.

Migration Steps

  • Setup Classic ASP Application
  • Create Dockerfile in the same application folder
  • Create local Docker image
  • Push the Image to Azure Container Registry
  • Create Azure Web App using Docker image

Classic ASP Application

For the purpose of this tutorial I am going to create classic ASP and will migrate that to Azure App Services. I have a very simple application with header, footer and page content.

The application is configured in IIS 10.

Docker File

The next important step of the migration is Dockerfile. We place the Dockerfile in the same folder.

The Docker file (available in source code) will install all the necessary Windows features and setup the application within the container image. In a real life scenario you might have an application with a database like SQL and you might be using DSN on your existing Windows machine. If DSN is required, then search the Docker file and update the DSN setting. You can see in this example that I have set the placeholder for the DSN setting.

Once we have the  Dockerfile, we need to build the code and create the Docker Image using following command,.

docker build -t aspclassic -f dockerfile .

After a successful build our image is ready. We will run the image locally and test.

docker run -d -p 8086:80 --name aspclassicapp aspclassic

If we browse the localhost:8086 we can see that Classic ASP is running from the docker container. Our container is ready to be pushed to Azure Container Registry.

Create Azure Container Registry (ACR) and Pushing Image

ACR is container registry for saving the docker images. We will push the latest image to ACR and later pull this image in Azure App Service.

Create ACR from Azure Portal.

After the ACR is created, login to Azure CLI (Powershell)

az login

Login to ACR ( classicasp is ACR name in my case. you need to choose what you created in previous step)

az acr login --name classicasp

Tag the image with ACR name and path ( classicasp.azurecr.io is path of my ACR. You can go to the Azure portal (or CLI) and find the name of your ACR)

docker tag aspclassic classicasp.azurecr.io/aspclassic:latest

Push the image to ACR

docker push classicasp.azurecr.io/aspclassic:latest

Once the image is pushed to ACR, you can browse ACR and check for the image.

Create Azure Web App

Next and final step is to create Azure App service for the container. Go to Azure portal and choose Web App for Containers

Fill the basic info and choose windows container.

Next fill the docker tab. Choose the ACR you created in previous step.

Once you have filled the mandatory info simply create the app service. You should have app service ready in few minutes. You can browse the URL and there you go!

For more information please click here

Author: Imran Arshad, Development Lead at Olikka
Passionate developer and Architect. Loves to learn and explore new technologies.  Imran has worked on different stacks and technologies including but not limited to ASP.NET CORE, SharePoint, Azure, AWS, Angular 5 , JQuerySQL and much more.