🆓 Grab your FREE Azure Stickers now! Limited to first 10 folks!
📺 Watch the video : How to deploy your web app in Windows Containers on Azure App Service.
💡 Learn more : Run a custom Windows container in Azure .
Sometimes you have a web application that runs on the full .NET Framework and has dependencies to libraries and capabilities that aren't available in a service like Azure App Service Web App. Applications like this sometimes rely on things to be installed in the GAC (Global Assembly Cache). In the past, you could only run an application like that in Azure if you run it in IIS on a Virtual Machine or in Azure Cloud Services. Now, you can run such an application in a Windows Container in an Azure App Service Web App. This enables you to use features like automatic scaling, deployment slots, testing in production and easy authentication and authorization.
In this post, we'll containerize an existing ASP.NET Forms application and run that in a Windows Container in an Azure App Service Web App.
If you want to follow along, you'll need the following:
Let's start by containerizing our existing application. I have an existing ASP.NET Forms web application that runs on .NET Framework 4.7. This is a very simple application and you crate your own by simply creating a new APS.NET Forms application in Visual Studio. Let's containerize it:
(Adding Docker support in Visual Studio)
(Publish wizard in Visual Studio)
(Create a new Azure Container Registry in Visual Studio)
Now that the container image is in an Azure Container Registry, we can use it to create a new App Service Web App and run the application in it.
Go to the Azure portal
Click the Create a resource button (the plus-sign in the top left corner)
Click on Web App. This opens the Create Web App blade a. Under Resource Group, click Create new and fill in a name for the new Resource Group b. Fill in a Name for the Web App c. For the Publish setting, select Docker Image d. For the Operating System, select Windows e. Select a Region near the location of the Azure Container Registry. This will speed up the deployment process f. Click Next: Docker
(Create Web App blade in the Azure portal)
g. Select Azure Container Registry for the Image Source h. For Registry, select the container registry that we've created before i. For Image, select the image that we've pushed into the registry. This will be called something like mywebformsapp j. For Tag, select latest k. Click Review and Create and click Create in the next screen. This will create the Web App
(Docker configuration of the Web App in the Azure portal)
When the Web App is created, go to it in the Azure portal. In the Overview blade, you'll see the Web App URL. Click on it to open it in a browser. This will show you a screen that says that the container is starting up.
(Web App's container is starting up)
It will take several minutes before the container starts. You can check what is going on in the background by going to the Web App in the Azure portal and looking at the Logs in the Container settings.
(Container logs in the Azure portal)
After a couple of minutes, try the Web App URL again in a browser to see the application in action, running in Azure.
(Application running in Azure)
Sometimes, you need a lot of control over the environment that your app runs in. A container can give you that control, as it acts as a complete virtual environment in a sandbox. And now, you can run Windows Containers on Azure App Service Web App. This give you control and a lot of cloud-only functionality, like automatic scaling, deployment slots, testing in production and easy authentication and authorization. Go check it out!