For a couple of months ago, I was asked to migrate low coding Mendix IaaS applications to Platform-as-a-Service (PaaS) services in Microsoft Azure Cloud. With as goal high availability (HA) scalable and multi cloud portability where developers can focus on delivering business value with CI/CD pipeline. And limit the maintenance of the servers or operating systems. It has never been easier to deploy container-based web apps for Linux. Just pull docker container images from a private Azure Container Registry into an Web App and it will deploy the containerized app with your preferred dependencies like PostgreSQL/MySQL; Storage to production in seconds.
The platform automatically takes care of OS patching, capacity provisioning, and load balancing were scaling is done in minutes & simple as dragging a slider, calling the REST API or configuring automatic scaling rules with automation accounts. For that reason, I have chosen for a Linux web app for containers to build Docker images and put them into containers. Docker is an open source container technology it is a highly scalable solutions and automated for delivery pipelines (CI/CD). I will explain how to build and run Mendix Docker image using the Mendix Docker Buildpack in combination with some dependencies: Azure web app for containers; Azure PostgreSQL & Azure container registry + Azure storage.
A Mendix Docker image is uniquely created for each release of a new version of the application using a Buildpack with settings. To run such a docker image we will use a Linux web app, you can also use one of the following Docker container services based in Azure cloud:
- Azure Container Services
- Other vendors
Azure Container Instances makes it easy to create and manage Docker containers in Azure, without having to provision virtual machines & it is one of the hottest technologies in cloud computing today to go fully PaaS. Deploy into Web Apps for Containers that scale with your business needs completely with Azure Autoscaling.
To automate the build, test, and deployment phases of the application development and be Agile on your terms, unlock collaboration with other teams, you can use a continuous integration and deployment (CI/CD) pipeline.
Azure Web App for Containers & Setup Architecture
Web App for Containers will deploy their containerized application and provision required infrastructure within Azure. When pushing a container image to Azure Container Registry it can be applied to the Web App for containers. A Docker Container is an isolated application platform. It contains everything needed to run your application, and is based on one or more Docker Images. Containers are created from Images.
The Architecture can be done in different forms.
- The multi-tenant systems that support the full range of pricing plans
- The App Service Environment (ASE) which deploys into your VNet.
One way is to deploy an Linux Web applications in an app service plan with a Application Gateway (AGW) enabled with WAF. Or to isolate the Linux Web App for containers within an Azure App service environment (ASE), this setup will deliver you a isolate web applications into an Azure virtual network (VNet) & connectivity integration to On-premises DC. For an Azure App service with dependencies I recommend using Azure Blob Storage an a database as a service (e.g., Azure Database for PostgreSQL) separately for your data needs to optimize scale and performance on application level. So now we can create A containerized deployment architecture using Microsoft Azure Web App for Containers.
Tip Application settings - VSTS Variables
Note that within VSTS appsetting.LICENSE_KEY must stand for it. The value itself for custom values begins with MXRUNTIME is case sensitive! If Container does not exist is will be automatic created.
Note that within VSTS appsetting.LICENSE_KEY must stand for it. The value itself with capital letters.
ADMIN_PASSWORD = Password default Mendix
CF_INSTANCE_INDEX = Used for Container scale out and prevent database locks Value = 0
DATABASE_ENDPOINT = Example PostgreSQL postgres://<username>:<password>r@<servername>.postgres.database.azure.com:5432/<databasename>
LICENSE_ID = License ID Mendix
LICENSE_KEY =License KEY
MXRUNTIME_APPLICATIONROOTURL = Public root URL
MXRUNTIME_com_mendix_core_StorageService = (value) com.mendix.storage.azure
MXRUNTIME_com_mendix_storage_azure_AccountKey = Azure storage key
MXRUNTIME_com_mendix_storage_azure_AccountName = Azure storage name
MXRUNTIME_com_mendix_storage_azure_Container = Azure storage container
DEBUGGER_PASSWORD = For Mendix modeler remote debugging
Getting started with Docker on Azure Web App
Getting started with Mendix app on Azure Web App for containers is quite easy. In this demo you will create a custom Docker Image to a Azure container registry to deploy it into an Web APP and some necessary variables. Attached to this post I provide a web URL of Mendix where you can find the Prerequisites and other useful information Mendix files .
Creating the Azure Container Registry
- Select Create a resource > Containers > Azure Container Registry.
- Enter values for Registry name and Resource group.
- SKU: Details of the features and limits of the Basic, Standard, and Premium service tier can be read on Microsoft site. For now Basic is enough.
- Under Admin user, select Enable. Create username & access key to manage the container.
Creating the App Service Web Apps on Linux
- Within the Azure Portal, search the Marketplace for Web App on Linux.In the blade that appears, click Create
- Enter the App name, Resource Group, and select an App Service Plan based in Linux to create the Web App on Linux.
The Web Apps on Linux deployed right now. This might take a couple of minutes.
Find and download the latest Docker logs using Kudu & Azure Portal
The docker logs shows information logged by the running container in the Web App Microsoft has an API that allows you to see the current Docker log details and you can download the current Docker logs in Zip format to investigate the logging https://[site].scm.azurewebsites.net/api/logs/docker. Insite the Azure Web App you find it on the left slide bar Development tools – Advanced Tools – Click in GO. under Rest API download current Docker logs (Download as Zip).
Microsoft makes it also possible to see the latest entries in the portal itself. Click on Container settings under settings and you see the log information from the container and Download and copy the logs, see picture below. After setting up the basics we can now proceed with deploying from Visual Studio Team Services VSTS
Continuous integration and continuous deployment (CI/CD) capabilities
I have eliminated the CI/CD aspect of a deployment and it will just demonstrate how to build and publish the containerized application directly from your Visual Studio (VSTS) to an Azure App Service through Azure Container Registry.
The following image at the side shows the workflow for the Azure Resources itself. In the video demo you see the global deployment of a complete project where the repository is directly from a Subversion for source control with VSTS local VSTS git is also possible but need manual steps for upload project files . If needed you can setup extra steps like approvals & triggers.
- Code + App files from remote repository
- Push Image to Azure Container Registry
- Update Web App for Containers with parameters based on latest build id/Docker Image tag.
The requirements to deploy resources on Azure using VSTS as part of CI/CD process you needs to establish an connection with Azure and ensure it has proper permissions to manage resources. The default is to setup /configure an client key with Azure AD App and authentication method supported by the Azure portal is Client ID + secret key. This is not part of this blog for more info to create an Azure AD APP registration see LINK.
In this demo I use a couple of task and may you need add some of it from the Marketplace:
- Shell exec (Build)
- Docker (Build & Push)
- Azure App Service Deploy (Release)
- Apply variables to website (Release)
#Shell Script to download Mendix Docker Build Pack (part of build pipeline)
mv docker-mendix-buildpack-master/* .
rm -R docker-mendix-buildpack-master
# Image TAG for Azure container registry & reuse the TAG for update the Web App
#Image Name (DEMO = repository in Azure Container registry)
Tip VSTS agent Capabilities
When using the agent hosted Linux preview (hosted) with default settings you may be getting an error. Into the system capabilities the setting svn- /usr/bin/subversion is not added by default bit is into the agent image. Add a new user capabilities svn- /usr/bin/subversion
Every agent has a set of capabilities that indicate what it can do. Capabilities are name-value pairs that are either automatically discovered by the agent software, in which case they are called system capabilities, or those that you define, in which case they are called user capabilities.
Deploying containers to Azure Web Apps for Containers is a great experience. We have successfully deployed a containerized application using Azure Web Apps for Containers in an Azure app Service plan and in preview you can deploy it in to the App service environment (ASE), and set up a continuous deployment pipeline for the application (In my case a Low Coding Mendix App). And you don’t need specific knowledge if clusters etc. You can create an Azure application gateway in front of you’re line that allows you to have an Azure Web App service as a back-end pool member with WAF and SSL offloading to protect the Web App and application. Read more on Talking Azure “Enable Web Application Firewall for your Application“. If you want you can now make use of the other built-in features of Azure Web Apps and Ci/CD VSTS features but is for now beyond the scope of the current post.
Docker image integration & Joint strategic investments to drive containers forward, Docker is an open source engine that automates the deployment of any application as a portable, self-sufficient container that can run almost anywhere. With Partnership we can enable the Docker client to manage multi-container applications using both Linux and Windows Server containers, regardless of the hosting environment or cloud provider. It is fine to see that “Microsoft ♥ Linux”.
The deployment of containers into Azure is easier than ever before!