Container? Why not App Services?


In this post, Senior Premier Developer Consultant Casey Kriutzfield gives a walkthrough of deploying Linux Containers in Azure App Services.


Containers have been popular lately, and Microsoft Azure has several products that are ready and able to serve your containers. Azure Kubernetes Service, Azure Container Instances, and Service Fabric are all great places to run enterprise containers and many organizations are spinning those services up. There is another place to run your containers, and it can be forgotten among the popular ones I mentioned.

A standard App Service.

Specifically, the Web App for Containers. With this product we are able to target a Linux Web App Container and deploy it into a Web App inside a Standard App Service. Doing this is fairly easy, and we get all the benefits of the App Service we are used to including Custom Domains, the ability to Scale Up and Scale out, Diagnostic Logs, Monitoring, and more. These features we can configure with Kubernetes, or another orchestrator inside Azure, but if we are hosting a web site inside a container, this is a pretty good option.

To get started, from the Azure Portal we are going to find the App Service Plans and create a new App Service Plan. We will name it “MyAppServicePlan”, and also create a new Resource Group called “My Resource Group”. In this case, we are going to want to create a “Linux” App Service Plan, as Windows on Containers is not yet supported. We are also going to keep the default Location as well as the Standard S1 Pricing Tier.

Once the App Service Plan is configured, we can click “Create” and we will be ready to go.

clip_image002

For the purpose of this example, we are going to use an ASP.NET Core 2 application I’ve called “SimpleWebApp”. You can get the solution from my GitHub site here.

The site itself is actually pretty simple. It’s just a page that displays “Simple Web App” but will also display the name of the machine it’s on. When you’re running the application locally with Visual studio, it will give you a display that looks a little something like this:

clip_image003

However, when you’re running the application inside a container, it will give you a display that looks a little something like this instead:

clip_image004

Of course, the machine names here depend on the name of your development machine, as well as the machine name Docker selects, but the point here is we can clearly see here that we would be running inside of a container. The code that’s part of the solution in GitHub has the Dockerfile and is ready for you to build and use. Also, the container has been pushed to the Docker Hub and is located at ckriutz/simplewebapp (https://hub.docker.com/r/ckriutz/simplewebapp/). For our example, we will use this image.

We need to click “Create a Resource”, and look for “Web App for Containers”.

clip_image005Once you find it, we can create a new one and it will bring us to the right blade.

The first thing we want to do is configure the container we want to use, we will select “Docker Hub” for our example.

Next, our solution is a public solution, so we will select “Public”.

Finally for “Image and optional tag”, we will type in ckriutz/simplewebapp:latest.

Clicking “OK” will satisfy our blade and we can configure the rest of the App Service.

clip_image006

The App Service itself is going to be straightforward. Our App name needs to be unique. I got lucky and called it “SimpleWebAppContainer”, but you’ll want to select something close that’s available. Select your Subscription, and then we will use the existing Resource Group we created before: “MyResourceGroup”. Along with that, we will use the App Service Plan we created before: “MyAppServicePlan”. With those settings, we click “Create” and we are good to go.

clip_image007

When everything is all done, we should have our App Service up and running with our container inside. With a URL ready for us, all we need to do is click on it and we should see our ASP.NET Core 2 container up and running!

Comments (0)

Skip to main content