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
- 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 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.
Hello, I thank you for your exceptionally good demo for containerizing classic asp and installing on Azure. However, I get with your source code the following error in deployment phase: “The parameter WindowsFxVersion has an invalid value. Cannot run the specified image as a Windows Containers Web App. App Service supports Windows Containers up to Windows Server Core 2019 and Nanoserver 1809. Platform of the specified image: windows, Version: 10.0.18362.658”
Hi there,
Thanks for reaching out to me and pointing out . Yes I verified there is problem with the existing image and that’s potentially because Microsoft recently did upgrades to their platform.
So I have updated the docker file (In the same project @ Github) that works for Azure web apps. Try the latest code here https://github.com/ImranMA/CodeSamples/tree/master/aspClassic-Docker and see if that works for you ?
Regards,
Imran
Yes, Imran, you found a working base image – so thank you very much. I also described in https://serverfault.com/questions/1006250/container-does-not-start-in-azure-or-deployment-is-prevented-due-to-compatibilit another issue I faced in local enviroment while building the container. I have no clue why this takes place – but let see if someone knows.
Hey, great article!
Could you please clarify what are benefits in using docker container in this case, comparing to deploying the Classic ASP app to Azure App Service directly?
Hi Vasilii,
Thanks for your appreciation. As of today ASP Classic is not supported native in Azure App Service. So only option you can deploy is using container.
I liked your detailed article about deploying a Classic ASP app through a container & an advantage I see is how build & delivery automation can be set up.
Although there is not much documentation of Classic ASP running on Azure Web App, it is possible to run such without any configuration changes. I deployed and tested a sample successfully through Kudu. There are also some scenarios discussed here – https://docs.microsoft.com/en-us/answers/questions/47909/how-to-connect-a-classic-asp-application-hosted-in.html
Thank you @mvark . Through Kudu is another interesting perspective and I have look.
Hi Imran,
Thanks for the article, I am trying to containerizing classic asp application with SQLDB. When I try Powershell commands to install windows feature, the build is failing. Not sure what is going wrong. Would like your advise.
Hi Jayasanker , thanks for reaching out. Do you like to share the logs or error message ?
This is great, I’m going to try this out. My asp app has a SQL backend, if I migrate that to AzureSQL can I still use this approach?
Hi Imran,
How can we enable web jobs for classic asp? I see they are disabled