How to deploy your web app in Windows Containers on Azure App Service

By | June 4, 2020

With Containerization getting popular nowadays due to its capabilities of reducing issues with regards to deploying applications on different environments and streamlining your compute resources, it makes a lot of sense that you should containerize your applications whenever it is possible.  With containerization your application will be bundled together with all of its related configuration files, libraries and dependencies required for it to run in an efficient and bug-free way across different computing environments.

Now how do we do that with your current legacy web applications? Well its is easy by using Visual Studio and an Azure Subscription, you will just need a few clicks and you wont believe your legacy app will be containerized in Docker on the cloud.

Lets start, first you will need to install Docker Desktop because later we will configure that Docker Desktop to run that application you had deployed in Azure.

During installation, set the default container type to Windows containers if you skipped to do that or you have already Docker Desktop installed, just switch it from the Windows system tray.

Now, that’s sorted, we can now park it for a while.  Let’s go to your legacy application.  Fire up your Visual Studio and open the legacy application you want to run on a containerized environment.  For our example I will be converting one of my web application called reservinator.

Once it opens, right click on the Web Project and choose Add –> Docker Support

What that does is that it creates this Dockerfile which is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

This is what the auto-generated file looks like.  Leave it as it is

Thats all you need, now lets publish it in your Azure tenancy.

Like your normal publish command right click on your project, choose and click Publish.

Publish screen will appear, now choose, Publish then Start

Now you will be presented with multiple publish target, we want to go for the Container Registry then Create New Azure Container Registry.  Then click on Create Profile.

Now let create and Azure Container registry, this allows you to build, store, and manage container images and artifacts in a private registry for all types of container deployments.  In this case it will be were it will be built and stored.

Now choose a DNS Prefix, this will be the name for you registry and it will be the suffix of the URL for your container.

Then you choose what subscription you will be using, then the resource group, SKU and Registry Location.  Once done click create.

At the back I created the necessary commands to tell Azure and all you need to do is to click Publish

This might take some time depending on your application, so take a break, have a coffee or you can see whats happening.

Once its done, go to your Azure and check if that container you created exists.  Go to Container registries and you will see a list of containers, find the ones you created.

Now we are pretty much sure that Container was created, lets now create an App Service and pull that image from that Registry.  Search for App Services, then create a new one.

Choose a subscription, this should be similar to the subscription you used when creating the Container.

Choose a resource group, similar to the subscription, your App Service should be on the same resource group as the container.

Choose a name for your site.  This will the URL you will access your site for the first time.  So if you name your app as xxx it will become  You can assign a different URL later.

Now choose Docker Container under the publish section, since we will just grab that from the container.

And Windows as operating system

Choose a region, here it is best to use where the geographical location of you users who access your web application the most.

Then finally your App Service Plan, give it a Windows Plan name and the SKU and size.  Take note Premium Container PC2 will be the smallest configuration you can configure it to.  There are not test/development SKU size with Docker Containers.

Now click Next: Docker

Now lets pull that baby (image of your published web app) from the container.

On Image Source select Azure Container Registry, because this is the place you published it from.

Then choose the Registry name, then you will see the Image of your web application, choose from the tag in our case it is the latest, then click Review + Create

There you go, your deployment to this App Service is on the way

Once done, it will look like this

That’s it, you containerized site is live and you can now access it on the URL indicated on the App Service URL Section

now lets go to that URL, and yes it is starting up for the first time, it will be slow at this first stage, but succeeding ones will be a breeze.  Its like the first time your site has run.

Now if you cant wait, you can view at the logs of whats happening on the background by going to your App Service then into Container Settings, under the Logs section.  If you are used to the Azure DevOps logs that shows you what happens on a real time basis, this log section in App Service is static, so you have to click refresh to see the updates.

Once you see it is done, go back to the site, refresh and whoalla! your first containerized app on the cloud.  Congratulations.

Now how about running it on Docker Desktop?

Right let us download that image but before doing so lets get more information where we can pull the image.

First go to your Container Registry, then under settings go to the Access Keys, there you will see the Login Server, Username and a couple of passwords

Now open Powershell (not the ISE) then run the docker login command

docker login --username xxx --password xxx

replace the xxx with the correct info you gathered from the Access Keys section

Now lets pull that image and to get that pull command, go to your repository and choose the tag that you want, in our case its the latest.

Here you will see, the Docker pull command.

Copy that and paste it on your Powershell session, hit enter.  It will now start to get that image.

docker pull

again replace the xxx with the correct info or just copy and paste it.

When its done check your docker desktop and you will see the image you just pulled.  Go to the side menu then choose open browser, and whoalla, its in your local.

There you go, I told you its easy.



Leave a Reply

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