Solutions
Markets
References
Services
Company

Use Azure Container Instances for NAV

11. October 2017

Use Azure Container Instances for NAV

Running NAV inside a Container has many benefits but one of the probably most obvious ones when you start to work with it is the ease of deployment: Running a NAV container with SQL and WebClient embedded is as easy as docker run -e ACCEPT_EULA=Y navdocker.azurecr.io/dynamics-nav1. But that assumes that you have Docker installed and running and to keep it running you’ll need to maintain it. By no means a big effort but how about eliminating even that?

This is where Azure Container Instances come into play. Container Instances are a relatively new addition to Azure and currently in preview, but already supporting Windows Containers. Azure Container Instances have roughly the same effect on a Docker / Windows Container environment that Azure has on a virtualization environment: You move the abstraction one level up and with that don’t need to care about the levels below anymore. With Azure VMs you no longer have to care about the infrastructure and the hypervisor but if you run Docker inside it, you still need to maintain that. With Azure Container Instances you no longer have to care about infrastructure, hypervisor and Docker. All you need to do is provide an image, some parameters and after waiting for a bit, your Container instance – in our case a SQL Server, NAV Server and WebClient – is up and running. Freddy Kristiansen, Jakub Vanak and I tried to explain that in our recent sessions at Directions NA and Directions EMEA with the following image2. The first morph shows that the move from VMs to Containers eliminates the need to worry about Guest OSes in VMs3. The second morph shows that with Azure Container Instances even Docker itself gets taken care of, so really all we need to worry about are the containers themselves. See how many of the boxes just disappear and with them the need to install, maintain and update? That definitely means that your control over them also disappears to some degree but depending on your scenario you don’t need that control anyways or you are willing to sacrifice control for ease of use and speed

So much for a very quick introduction into Azure Container Instances. If you want to really know what they can do, I’d suggest the initial announcement and the documentation4, but I hope you got the idea from my description as well and understand why it matters. So, how can we use that with NAV? It is extremely easy:

  1. Get an Azure subscription and log in to portal.azure.com
  2. Open a Cloud Shell, another nice recent addition to Azure. I’ll use the bash-based flavor5
  3. Create a resource group (necessary prereq for a Container Instance) with
    az group create --name navGroup --location WestEurope
  4. Create the Container Instance with
    az container create --name navcontainer --image navdocker.azurecr.io/dynamics-nav:devpreview-finus --registry-login-server navdocker.azurecr.io --registry-password "<password>" --resource-group navgroup --registry-username "<username>" --os-type Windows --cpu 2 --memory 3 --environment-variables ACCEPT_EULA=Y --ip-address public --port 443

    This creates a container with 2 cores and 3g memory based on the devpreview-finus image, publicly accessible through https. You’ll need to replace the username and password parameters with the correct values. If you don’t have them, ask Freddy Kristiansen or someone who attended one of our workshops.

  5. Wait for a couple of minutes as pulling and extracting the image takes some time. You can check the state with
    az container show --resource-group navgroup --name navcontainer
  6. When you see
    ...
      "ip": "13.95.90.158",
    ...
      "provisioningState": "Succeeded",
    ...
      "state": "Running",
    ...

    then you are done and you can connect to https://13.95.90.158/NAV/WebClient (check the container logs with az container logs --resource-group navgroup --name navcontainer to find user and password). Or just wait until the Azure portal shows something like this where you can also see the state information and the IP address

In the end, you’ll have something like this (which could be running anywhere but actually is a Azure Container Instance)

So, as a recap: If you have an Azure subscription, you just need to enter two lines of code and wait a couple of minutes, and you can get your own Docker-based NAV in a Windows Container without installing anything! Microsoft,

Update

As the NAV Docker images are now publicly available, step 4 above can now look like this and you don’t need the password for the private repo:

az container create --name navcontainer --image microsoft/dynamics-nav:devpreview-finus --resource-group navgroup --os-type Windows --cpu 2 --memory 3 --environment-variables ACCEPT_EULA=Y --ip-address public --port 443

I’ve also created an ARM template for this that got accepted at the Azure quickstart templates repo, so you actually can just go to the Azure github repo and hit “Deploy to Azure”. There you’ll have to accept the EULA, set a username and password for your NAV admin user and after a couple of minutes, you have your Azure Container Instance running NAV!

  1. on Windows Server 2016. On Windows 10, you’ll need to do docker run -e ACCEPT_EULA=Y -m 2g navdocker.azurecr.io/dynamics-nav because of the way containers and especially memory isolation works there. Sad!
  2. this is a slightly simplified and hugely more animated version as we don’t need to stand next to it and won’t be embarrassed by it
  3. and a lot more, but for the current topic, I’ll oversimplify a bit although as a Docker fan it is tough not to mention all the goodness it brings
  4. by the way, remember the days when documentation across all vendors was horrible? A lot of them found good ways how to improve that, Microsoft being one of the best in my opinion
  5. Why? Because it works and I still find it funny to orchestrate a Windows Container Instance on Microsoft Azure with bash. But that’s just me, you can go for PowerShell as well, obviously with different syntax and commands

3 Kommentare zu “Use Azure Container Instances for NAV”

  1. Hi Tobias,
    I tried your example (Copy and paste with Cloud-shell Bash), but it doesn’t work.
    Is there anything to consider in addition to the two lines of code?
    The result of the show-command below:
    {
    “containers”: [
    {
    “command”: null,
    “environmentVariables”: [
    {
    “name”: “ACCEPT_EULA”,
    “value”: “Y”
    }
    ],
    “image”: “navdocker.azurecr.io/dynamics-nav:devpreview-finus”,
    “instanceView”: {
    “currentState”: {
    “detailStatus”: “”,
    “exitCode”: null,
    “finishTime”: null,
    “startTime”: “2017-11-23T09:57:21+00:00”,
    “state”: “Running”
    },
    “events”: [
    {
    “count”: 1,
    “firstTimestamp”: “2017-11-23T09:56:39+00:00”,
    “lastTimestamp”: “2017-11-23T09:56:39+00:00”,
    “message”: “Successfully pulled image \”navdocker.azurecr.io/dynamics-nav:devpreview-finus\””,
    “name”: “Pulled”,
    “type”: “Normal”
    },
    {
    “count”: 1,
    “firstTimestamp”: “2017-11-23T09:56:39+00:00”,
    “lastTimestamp”: “2017-11-23T09:56:39+00:00”,
    “message”: “Created container with docker id d433537a6a8d”,
    “name”: “Created”,
    “type”: “Normal”
    },
    {
    “count”: 1,
    “firstTimestamp”: “2017-11-23T09:57:21+00:00”,
    “lastTimestamp”: “2017-11-23T09:57:21+00:00”,
    “message”: “Started container with docker id d433537a6a8d”,
    “name”: “Started”,
    “type”: “Normal”
    }
    ],
    “previousState”: null,
    “restartCount”: 0
    },
    “name”: “navcontainer”,
    “ports”: [
    {
    “port”: 443,
    “protocol”: null
    }
    ],
    “resources”: {
    “limits”: null,
    “requests”: {
    “cpu”: 2.0,
    “memoryInGb”: 3.0
    }
    },
    “volumeMounts”: null
    }
    ],
    “id”: “/subscriptions/7e6952a5-4286-496e-a9c4-0ed46df6bebf/resourceGroups/navgroup/providers/Microsoft.ContainerInstance/containerGroups/navcontainer”,
    “imageRegistryCredentials”: [
    {
    “password”: null,
    “server”: “navdocker.azurecr.io”,
    “username”: “7cc3c660-fc3d-41c6-b7dd-dd260148fff7”
    }
    ],
    “instanceView”: {
    “events”: [],
    “state”: “Running”
    },
    “ipAddress”: {
    “ip”: “52.232.6.38”,
    “ports”: [
    {
    “port”: 443,
    “protocol”: “TCP”
    }
    ]
    },
    “location”: “westeurope”,
    “name”: “navcontainer”,
    “osType”: “Windows”,
    “provisioningState”: “Failed”,
    “resourceGroup”: “navgroup”,
    “restartPolicy”: “Always”,
    “tags”: null,
    “type”: “Microsoft.ContainerInstance/containerGroups”,
    “volumes”: null
    }


Leave a Reply

Your email address will not be published. Required fields are marked *