Automating Docker Deployment with Azure Resource Manager

Recently, I had to build a solution where Docker container were appropriate. The idea behind the container is that once there are built you just have to run it. While it's true, my journey was not exactly that, nothing dramatic, only few gotchas that I will explain while sharing my journey.

The Goal

The solution is classic, and this post will focus on a single Virtual Machine (VM). The Linux VM needs a container that automatically runs when the VM starts. Some files first download from a secure location (Azure blob storage) then passed to the container. The solution is deployed using Azure resources manager (ARM). For the simplicity, I will use Nginx container but the same principle applies to any container. Here is the diagram of the solution.

Docker-in-Azure2

The Solution

I decided to use Azure CLI to deploy since this will be also the command-line used inside the Linux VM, but Azure PowerShell could do the same. We will be deploying an ARM template containing a Linux VM, and two VM-Extension: DockerExtension and CustomScriptForLinux. Once the VM is provisioned, a bash script will be downloaded by CustomScriptForLinux extension from the secure Azure blob storage myprojectsafe, then executed.

Reading Notes #235

ImaginationSuggestion of the week


Cloud


What's your plan B when the Azure Portal is not responding

(Ce billet en aussi disponible en français.)

You are about to test the last version of your solution. You just need to change some configuration in the Micosoft Azure Portal, and you are good to go. To do it, you log in the portal at http://portal.azure.com and navigate to your component and... Error! What you see is a little sad cloud.

OneSadCloud

The Problem

This just happened to the team I'm working with. They needed to change the traffic manager's endpoint to do a traffic test. Unfortunately, the grid that contains the Endpoint was in a bad status and was not available. It looked like a deadened!

ManySadClouds

But it is really? Of course not. Here what you can do.

The Solution

Remember Microsoft is sharing the same API the Azure portal is using. That the beauty of the Azure Portal, you can use it has a convivial way to do your what you need, or you can access it via many different SDKs that are available today: .Net, Java, Node.js, Php, Python, Ruby and more! You also have command line tools that could help to manage your Azure services and apps using scripts.
To know more about all the SDK available or the command-line refer to the Azure SDKs documentation pages online.

Remember

This time we were in a Windows environment, and we needed to modify one Endpoint of a Taffic Manager. Here what we did using Azure PowerShell Cmdlets:

# Login to our account
Login-AzureRmAccount

# Set the context we will work in. Use Get-AzureRmSubscription to list all your subscriptions. 
Set-AzureRmContext -SubscriptionName "MySubscriptionName"

# List All Traffic Manager Profile 
Azure Get-AzureTrafficManagerProfile 

# Load our endpoint in a variable, change the value we need and put it back.
$endpoint = Get-AzureRmTrafficManagerEndpoint -Name myendpoint -ProfileName myprofile -ResourceGroupName "MyResourceGroupName" -Type ExternalEndpoints
$endpoint.Weight = 50
Set-AzureRmTrafficManagerEndpoint -TrafficManagerEndpoint $endpoint


In this case, we used the Azure Resource Manager (ARM) commands, but all the commands are also available in the service mode. To know more about how to deploy with ARM you can read my previous post. To see all the command available supported with ARM to configure your solution, go see the documentation online.
Happy testing!


References: