Imran
Azure, Cloud, Container, Docker

Containerize and Migrate Legacy Classic ASP to Azure App Service

Download source code here

Legacy apps are sometimes very hard to modernize or not worth it so you just want them working in their current state without much overhead. Migrating the legacy application using Docker on Azure App Service gives you many benefits like better SLA, scalability and gets you free of OS management/ Patching and certainly longer shelf life. I recently migrated on-prem legacy classic ASP application by containerizing and then hosting it to Azure App Service and would like to share my experience and challenges.

Prerequisites

Migrating the ASP Classic may not be straight forward in some cases and it may require code changes . You need to evaluate application and check which part of application can be migrated as it is and what requires to be rewritten. E.g. Azure App Service does not allow the registration of COM/COM+ components on the platform. If your application make 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

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 and meat of this whole migration is dockerfile. We place the docker file 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 Docker file ,we need to build the code and create docker image using following command

docker build -t aspclassic -f dockerfile .

After 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 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 to save 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 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 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 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 mins . You can browse the URL and there you go !

Feel free to leave question/comment and i am happy to answer.

Like the post ? Share !

Related posts

Dockerize .NET CORE web App with dependent class library

Imran
December 17, 2018

Parallelize tasks with Azure Durable Functions

Imran
January 27, 2019

Microsoft Ignite|The Tour Sydney

Imran
February 17, 2019
Exit mobile version