User-friendly deployment using docker
Recently I’ve come over a scenario where docker is chosen to easily spin up demo environments for Dynamics NAV, tailored for different user cases, different customer industries and solutions. While docker is the preferred option here because it offers advantages such as portability and rapid deployment, it is primarily a tool for dev-ops.
The ease of configuration and management of containers is relative to how tech-savvy people are, and we needed to bridge the gap between the flexible powershell deployment used by developers and a user-friendly interface that anyone else would want to work with. Mind you, we are talking about different scenarios here, where some may require custom database, others need third-party .net solutions and so on, and all need to occasionally make smaller configuration changes once the container is created. For example, completing the Excel add-in registration. So, mainly scenarios that cannot be easily covered by Azure Container Instances and that users wanted to have provided ad-hoc. To retain flexibility for the users, while keeping them out of the docker-sphere, we decided to go with Azure Automation Runbooks and Custom Script Extensions.
Runbooks are used to automate your management tasks, and they come with webhooks and API. Custom Script Extensions enable additional customization of your VM. They can automatically download scripts and files from Azure Storage and launch a PowerShell script on the VM. The idea is this: the user fills in a list of parameters, whether directly in portal, or from any application/site invoking the API, and starts the process. Like this:
The example here is simplified and shows only the classic parameters. In reality, many more parameters are provided and some additional configuration is run, including copying database, license, Add-in and loading custom script files to VM. The runbook connects to the VM I specify, copies the files over and executes the script I provided on the VM – that is the Custom Script Extension I uploaded to the Azure Storage. The output is returned to the runbook:
Additionally, my client’s scenario was confined to Azure VMs, but if needed, one could add a hybrid worker role and deploy anywhere.
This enabled me to run customized deployments from one central place, with a user-friendly interface. The development process is simple:
- Upload your docker scripts (AdditionalSetup.ps1, … and all others) to Azure storage.
- Create a Custom Script Extension – basically a PowerShell script that will copy files over to the VM and execute new-navcontainer. This is uploaded to azure storage.
- Create a runbook. There are different kinds of runbook with different capabilities for different scenarios. I have chosen PowerShell runbooks here (workflows and graphs are also available). So, my runbook is basically a PowerShell script that will connect to Azure VM and invoke Custom Script Extension (another PowerShell script). The core parts are these:
I did have to cheat a bit and set some environment variables prior to calling new-navcontainer in CreateMyNAVContainer.ps1. Environment variables like UserProfile and Desktop, to get the shortcuts and all correctly provided, but that was really all there was to it.
And there it is: Docker, the user-friendly way to deploy
This was originally posted here.
*This post is locked for comments