Running Docker Containers in Microsoft Azure
There are multiple options for running Docker containers in Microsoft Azure. Below the options are broken out by the need to run an app in a single container or an app composed of multiple containers.
Monolithic (Single Container) Apps
An application does not need to be built out of microservices to benefit from the advantages of containers.
Developing a monolithic application in a container gives the advantages of dependency management, portability and ease of deployment.
Options for running single containers in Azure:
-
Azure App Service now supports running Docker containers using Linux. You can configure containers to be run using the Azure Portal or create a containerized application and deploy the container directly to App Service using Visual Studio.
You can setup a continuous delivery pipeline for your App Service in Visual Studio Team Services using the Continuous Delivery Tools for Visual Studio extension.
-
Azure VM - IAAS using ARM Templates
You can create your own VM using Azure Resource Manager (ARM) Templates and install Docker. From there you can use Azure VM Scale Sets to scale your service as needed.
Note that “Visual Studio Tools for Docker” is part of Visual Studio 2017 and available as an extension for Visual Studio 2015.
Service-oriented (Multiple Container) Apps
Containers really shine when it comes to building Service-oriented architectures. Using services gives the ability to scale only the required parts of the application and allows developers to improve a single part of the system at a time.
While the above sounds great, the hard part is keeping track of all the containers.
Tools that help manage the provisioning, scheduling and monitoring of containers are called orchestrators.
You can use just about any orchestrator with Azure because you can manually create VMs and install whatever you like on them.
Installing and configuring orchestrators is a complicated process. Microsoft has gone to great lengths to make configuring Orchestrators easier with the Azure Container Service (ACS)
Options for orchestrating containers in Azure:
-
Azure Container Service makes it easier to setup orchestration by pre-configuring the hosting environment and deploying the orchestrator for you. Select the orchestrator, the size and number of VMs and ACS takes care of the rest.
ACS currently supports (as of March 2017):
- Docker Swarm (not to be confused with the new Docker Swarm Mode)
- Kubernetes
- DC/OS
There are some great tutorials in the Technical Community Content repository on GitHub if you want to try out ACS.
You can setup a continuous delivery pipeline for your Azure Container Service in Visual Studio Team Services using the Continuous Delivery Tools for Visual Studio extension.
-
Azure Service Fabric is Microsoft’s orchestrator that was originally used internally for services such as Azure DocumentDB, Azure SQL Databases and Skype for Business. Service Fabric can be installed on premises or in a cloud provider such as Azure or AWS. Service Fabric can run Linux and Windows containers.
-
Azure VM - IAAS using ARM Templates
As with the monolithic containers above, you can provision your own VMs and install your own orchestrator.
There is a great example here on how to use the Azure CLI to setup and run Docker Swarm Mode in Azure.
A couple more good links:
- Microsoft e-book on Docker Containers and Azure
- Discussion of Container Strategies with Michele Bustamante on .NET Rocks
- Using Docker with App Service with Nick Walker on the MSDevShow
- Sample .NET Core reference application, powered by Microsoft, based on a simplified microservices architecture and Docker containers - Thanks Bill Pratt for the link.