«

»

Print this Post

CRS.RemoteNAVDockerHostHelper – my new PowerShell module

Note – The links and text have been updated to the latest version of the CRS.RemoteNAVDockerHostHelper module.  All screenshots are untouched though, so might refer to old naming/parameters/… !

I have been struggling in getting my head around managing “stuff” on Docker. You know – the new kid in town that will see its use in many fields. We implemented a Docker-based environment for Build-server, for local dev, and now also for test servers for customers. And as you know – you can use is for much more!

Docker Host

In any case, you need docker “somewhere”. Some people install it on their Windows 10 – but that would be something I would never recommend, because in my opinion, it belongs on a “server”, simply because the memory management is much better and all that.. .

You are probably familiar with AJ’s blogpost on how to setup a nice local Docker Environment based on a Windows Core in a Hyper-V. I find it the ideal way to work with docker images locally, to be used for local development, testing, previewing, … you know .. a flexible and clean way to manage many different builds of Dynamics NAV.

navcontainerhelper

You are also quite familiar with the navcontainerhelper, probably. I absolutely love that PowerShell module that Freddy created. It basically solves the problem to call typical Dynamics NAV cmdlets remotely. When you look at the code (it’s all available on GitHub, by the way), it’s full of “Invoke-Command”, meaning that a function in the navcontainerhelper-module executes a number of NAV cmdlets remotely on the container. It’s much easier to work with, because you avoid having to enter the container session, and execute the cmdlets one-by-one.

So, what is this new module all about then?

Well, the downside of having a windows core docker host – or any “remote” docker host for that matter – is that you still have to enter remote sessions, and execute PowerShell from there. Just consider the following scenarios:

  • I have an AzureVM with NAV on Docker, and I just want to develop my apps on my own local machine. Occasionally, I’d like to do tasks like update the container on that machine, or publish an app, or test the upgrade code of my app, or.. . That’s powershell!  If you do this manually, it could mean that you need to:
    • Log into the AzureVM (remote desktop? Enter-PSSession?)
    • Copy the app and make it available on the remote machine, on a specific place I can access from the container as well
    • Use navcontainerhelper to do stuff in PowerShell
    • Or enter the container to do stuff straight into the container.
  • I have a VM running on my laptop.  In this VM, I have docker containers. Kind of like the setup that AJ suggests (and works great for me). I want to develop on my laptop, but publish on the container. Anything container or VM related, I would have to
    • Log into the AzureVM (RDP or Remote PS Session)
    • Copy the app and make it available on the remote machine, on a specific place I can access from the container as well
    • Use navcontainerhelper to do stuff
    • Or enter the container to do stuff straight into the container.

So, in both cases – you need to log into another machine. And all I want to do is repetitive tasks time and time again.

CRS.RemoteNAVDockerHostHelper

That’s where my new module comes into play. It’s definitely not a replacement of the navcontainerhelper – in the contrary – it’s dependent on it for some tasks. But it’s one step further, for the cases you are not working on the same machine as you have installed Docker – which appear to be the majority of the times, in my case.

Examples

I created two examples. Basically for me to be able to test the module .. But also to illustrate in what way you are able to use them. All scripts where I use the module, can be found on my github in this folder here: https://github.com/waldo1001/Cloud.Ready.Software.PowerShell/tree/master/PSScripts/NAV%20Docker/RemoteDocker

You see it contains a number of folders. Each folder represents a scenario. So, it contains scripts to be run against an AzureVM (where you enabled Remote PowerShell), and the other folder “waldocorevm” works against my local VM that contains docker.

Both folders contain a _Settings.ps1, which basically contains the connection details for that specific scenario. All the other scripts in the folder, work with these settings and with the CRS.RemoteNAVDockerHostHelper-module, to do what it’s entended for.

For example if you want to test to upgrade an app, just look at the UpgradeApp.ps1 and you’ll see it’s quite simple. No remoting, nothing, just calling a “simple” powershell function from the module, and all will be done for you in the background. Here is an example of the clean-script being executed from my laptop, but is going to remove all apps on a container of my VM on Azure:

I know, nothing much exciting, but if you know it is actually “remoting” into two sessions – well – quite cool, if I may say so myself ;-). This is the clean-function from the module:

One thing worth mentioning is that it’s also going to take care about your App-file that you have on your local machine, but you might want to publish way up there in the cloud.  Just look at the Copy-FileToDockerHost, which is used by Install-RDHNAVApp for example :-).  SImple, and efficient!

Where can I get this module?

Well, the easiest is to just download it from the PowerShell Gallery, by executing:

Install-Module CRS.RemoteNAVDockerHostHelper

But it is also available on my Github alongside my other modules: https://github.com/waldo1001/Cloud.Ready.Software.PowerShell

Feedback

Any feedback is useful! If you want me to address specific things, most convenient is to provide feedback on github. But on this blog is fine as well ;-). You are always welcome to fork into the project like many other already have done, by the way :-).

Remote PowerShell

If you would like to read up on remote powershell, well, there is a lot of info out there. Just a few examples which were useful for me:

 

5.00 avg. rating (97% score) - 2 votes

Permanent link to this article: http://www.waldo.be/2018/02/08/crs-remotenavdockerhosthelper-my-new-powershell-module/

6 pings

  1. CRS.RemoteNAVDockerHostHelper – Updated! – waldo's blog

    […] CRS.RemoteNAVDockerHostHelper – my new PowerShell module […]

  2. CRS.RemoteNAVDockerHostHelper – Updated! - Microsoft Dynamics NAV Community

    […] that reason, I have edited my previous blogpost, where I introduced the new module. Still, since I (think I) made it a little bit easier for you to […]

  3. Export C/AL objects as AL from a database on a docker container on a remote host – waldo's blog

    […] That why I created new PowerShell modules – just to make that a bit easier. I described it earlier this year here. […]

  4. Export C/AL objects as AL from a database on a docker container on a remote host - Microsoft Dynamics NAV Community

    […] That why I created new PowerShell modules – just to make that a bit easier. I described it earlier this year here. […]

  5. Export C/AL objects as AL from a database on a docker container on a remote host - Waldo's Blog - Microsoft Dynamics NAV - Dynamics 365 Business Central/NAV User Group - Dynamics User Group

    […] That why I created new PowerShell modules – just to make that a bit easier. I described it earlier this year here. […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: