AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 08.02.2018, 05:22   #1  
Blog bot is offline
Blog bot
Участник
 
20,568 / 712 (65) +++++++
Регистрация: 28.10.2006
waldo: CRS.RemoteNAVDockerHostHelper – my new PowerShell module
Источник: https://dynamicsuser.net/nav/b/waldo...ershell-module
==============

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.R...r/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-NAVAppToDockerHost, which is used by Install-NAVContainerAppOnDockerHost 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.R...are.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:




Источник: https://dynamicsuser.net/nav/b/waldo...ershell-module
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
waldo: Import-NAVModules: An easy way to import NAV PowerShell modules Blog bot NAV: Blogs 0 30.06.2017 03:32
waldo: Convert C/AL Objects to AL with PowerShell Blog bot NAV: Blogs 0 05.05.2017 03:33
waldo: PowerShellGet & waldo’s PowerShell Modules Blog bot NAV: Blogs 0 17.01.2017 08:11
Navigate Into Success: Module Binder Pattern proposal Blog bot NAV: Blogs 0 15.10.2016 01:36
Microsoft Dynamics CRM Team Blog: PowerShell module for performing data operations and manipulating user and system settings in CRM Blog bot Dynamics CRM: Blogs 0 26.09.2015 01:14
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 12:31.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.