Custom Docker Containers in your Azure Web App - Part 2

Part 1 of this services, contains the details you need to create a Docker Image and Container locally to verify it's all working as you expect. Then build, tag, push it to a provisioned Docker Registry manually for use elsewhere.

Custom Docker Containers in your Azure Web App - Part 2

Part 1 of this series, contains the details you need to create a Docker Image and eventual Container locally, to verify it's all working as you expect. Then build, tag, push it to a provisioned Docker Registry manually for use elsewhere.

In Part 3 we'll look at the CD/DI pipeline to push our container to the site when new updates are available after checkin to our master branch in our git repository.

What we're going to look at here is the creation of the Azure Web App capable of deploying our customer Docker container.

Let's being.

First have a read though the [MS tutorial on creating custom docker containers in Azure Web Apps] (https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image) which should give you an great overview of what we're trying to do here and the indepth steps to do it in the Portal. I'm not going to reproduce that content here but I will cover some handy tips and the overview of the next steps to get the container executing environment setup.

Annoyingly at the time of writing you can only configure the Web App to accept a custom Docker container via console or powershell, you cannot do it via the Azure Portal. Also note I couldn't find a way of changing the Web App to use a custom container after it was provisioned. For example going from predefined Node Container Web App to a Custom Container later after provisioning. Make sure you get this right first time or you'll have to do the provisioning again, like me :D.

Second, if you don't have a Linux Service Plan (why would you, we're all Windows guys here, until now that is), you'll need to set one up for the containers to run in. With all Cloud resouces it's always best to start with the smallest resource you can and then scale up later if needed, so you get the best bang for your buck.

To setting up the Web App you need to either run this from the Portal Console, Azure Powershell via an ARM Template or simply from the Portal Blade under App Service Plan.

Third create the Web App and specify the custom container location. This can point to the public Docker Registry, an Azure Registry or another registry. We run our own Azure Registry for our sites and services. I've pointed the deployment container config at that. The Docker naming convention used here is "registry/owner/image-name:tag", a standard Dockerfile naming convention.

az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app_name> --deployment-container-image-name <docker-ID>/mydockerimage:v1.0.0

When this is setup and it can take a bit of time if there is a lot going on in the Docker Container at start up, when you navigate to the public site you should be able to see your site on port 80 of the Web App site.