Implementing extensions in NAV Development Preview using Docker
Introduction:
This blog describes Container, Docker, and Benefits of using Containers. As containers was a new functionality in Microsoft Dynamics NAV Development Preview from September Update, this document also demonstrates creating containers and how to implement extensions using containers. Also, it includes saving the image into Azure Container Registry Service.
Pre-requisites:
- Microsoft NAV Development Preview(December update)
- Visual Studio Code(VS Code)
Description of Containers:
1. What is a Container?
A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.
2. Why do we use container?
When you are running an app on a computer, you stand the risk that it will conflict with everything else on the machine. If two apps are having the same name and utilizing the same folder structure on the hard drive, there is a conflict and if 2 apps are using different versions of the same DLL, there might be problems.With a container, you achieve a higher level of isolation. Each container has its own file system, its own registry, its own network layer with its own published ports, and of course its own memory space – kind of like a virtual machine, just without the fat guest operating system.
3. What is a Docker?
Docker is the company driving the container movement and the only container platform provider to address every application across the hybrid cloud.Docker enables true independence between applications and infrastructure and developers and IT ops to unlock their potential and creates a model for better collaboration and innovation.
4. Implementing Docker:
What is a Docker Image?
An image is an inert, immutable, file that’s essentially a snapshot of a container. Images are created with the build command, and they’ll produce a container when started with run. Images are stored in a Docker registry such as registry.hub.docker.com.
i. List of Docker Images
ii. List of Containers
PS C:\Users\cfadmin> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c45e57849c56 microsoft/dynamics-nav:devpreview-finus "powershell -Comma..." 14 hours ago Up 2 minute s (healthy) 80/tcp, 1433/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:7046-7049->7046-7049/tcp, 7045/tcp, 0.0.0.0:8080->8080/t cp navserver
iii. Creating a new Container
PS C:\demo> docker run -e ACCEPT_EULA=Y a9 Initializing... Starting Container Hostname is 0b04fbea782e PublicDnsName is 0b04fbea782e Using NavUserPassword Authentication Starting Local SQL Server Starting Internet Information Server Creating Self Signed Certificate Self Signed Certificate Thumbprint 52600A924814D5A8848D7990BC3F76F7FB6FAF66 Modifying NAV Service Tier Config File with Instance Specific Settings Starting NAV Service Tier Creating DotNetCore NAV Web Server Instance Enabling Financials User Experience Creating http download site Creating Windows user admin Enabling SA WARNING: This license is not compatible with this version of Dynamics NAV. Creating NAV user WARNING: This license is not compatible with this version of Dynamics NAV. WARNING: This license is not compatible with this version of Dynamics NAV. Container IP Address: 172.18.232.162 Container Hostname : 0b04fbea782e Container Dns Name : 0b04fbea782e Web Client : https://0b04fbea782e/NAV/WebClient/ NAV Admin Username : admin NAV Admin Password : Tyvo6712 Dev. Server : https://0b04fbea782e Dev. ServerInstance : NAV Files: http://0b04fbea782e:8080/al-0.12.15359.vsix http://0b04fbea782e:8080/certificate.cer Initialization took 105 seconds Ready for connections!
Note:
- Instead of full Image ID starting few characters can be used as Identifiers.
- Image Name can also be instead of Image ID.
- Download the Certificate from the URL and installed in Enterprise Trust, Trusted Publisher.
iv. Viewing the created Container
PS C:\demo> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORT S NAMES 0b04fbea782e a9 "powershell -Comma..." 3 hours ago Up 3 hours (healthy) 80/t cp, 443/tcp, 1433/tcp, 7045-7049/tcp, 8080/tcp stupefied_stonebraker ca1980d041c6 microsoft/dynamics-nav:devpreview-finus "powershell -Comma..." 28 hours ago Up 6 hours (healthy) 80/t cp, 1433/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:7046-7049->7046-7049/tcp, 7045/tcp, 0.0.0.0:8080->8080/tcp navserver
Newly Created Container with name as ‘stupefied_stonebraker’ and ID as ‘0b04fbea782e’
5. In Visual Studio Code:
i. Contents of Launch.json file
ii.Contents of App.json file
iii. Contents of Code unit which displays a Hello Message
iv. Contents of Customer Card which Creates a field and an action that triggers the CodeUnit above
v. Contents of Customer Table Extension that adds a field
vi. in the Extension Management Pane
vii. Action in Customer Action
vii Displaying Hello Message
viii. Added field in the Customer Card Page
6. Merging the Containers in Image and Managing with Azure Container Service
i. Comitting the Container ‘stupefied_stonebraker’ to Image ‘microsoft/dynamics-nav:devpreview–finus’
PS C:\Users\vmadmin> docker stop stupefied_stonebraker stupefied_stonebraker PS C:\Users\vmadmin> docker commit stupefied_stonebraker microsoft/dynamics-nav:devpreview-finus sha256:eca05b64ed3619c688225685613e27fb4dbb6823aee46e24e96f3d813158440f
ii. Tag the Image ’ microsoft/dynamics-nav:devpreview–finus’ as ‘navcontainerregister.azurecr.io/dynamics-nav:v1’ and push the committed image to Azure Container Service
PS C:\Users\vmadmin> docker tag microsoft/dynamics-nav:devpreview-finus navcontainerregister.azurecr.io/dynamics-nav:v1 PS C:\Users\vmadmin> docker login --username NavcontainerRegister --password 6QiIyg9ICAa=aEg1jL2Wp8JumxvfPAEd navcontainerregister.azurecr.io Login Succeeded PS C:\Users\vmadmin> docker push navcontainerregister.azurecr.io/dynamics-nav:v1 The push refers to a repository [navcontainerregister.azurecr.io/dynamics-nav] 79bb52c8ab0d: Preparing 9c54b1a40ebc: Preparing 0d828dcd4895: Preparing b52bf723b284: Preparing 4beec416a215: Preparing 282537c6428c: Preparing b786ae432ac1: Preparing b07b88fd6145: Preparing 28c2b5be05f7: Preparing cc91b1f75f98: Preparing 7305c5891baa: Preparing bb5530559b18: Preparing 021428a01c82: Preparing 13b346524402: Preparing cda2d40c0d33: Preparing 64efa9cbaf9b: Preparing aa2b81bfb0aa: Preparing 505553846eae: Preparing 7a83b9538cb1: Preparing 20c2a3ed5225: Preparing 5437ac367abf: Preparing c856f8e0a2f7: Preparing f358be10862c: Preparing b07b88fd6145: Waiting 28c2b5be05f7: Waiting cc91b1f75f98: Waiting 7305c5891baa: Waiting bb5530559b18: Waiting 021428a01c82: Waiting 13b346524402: Waiting cda2d40c0d33: Waiting 64efa9cbaf9b: Waiting aa2b81bfb0aa: Waiting 505553846eae: Waiting 7a83b9538cb1: Waiting 20c2a3ed5225: Waiting 5437ac367abf: Waiting c856f8e0a2f7: Waiting f358be10862c: Waiting 282537c6428c: Waiting b786ae432ac1: Waiting b52bf723b284: Pushed 9c54b1a40ebc: Pushed 4beec416a215: Pushed b07b88fd6145: Pushed 282537c6428c: Pushed b786ae432ac1: Pushed cc91b1f75f98: Pushed 28c2b5be05f7: Pushed bb5530559b18: Pushed 021428a01c82: Pushed cda2d40c0d33: Pushed 13b346524402: Pushed aa2b81bfb0aa: Pushed 64efa9cbaf9b: Pushed 505553846eae: Pushed 20c2a3ed5225: Pushed 79bb52c8ab0d: Pushed c856f8e0a2f7: Skipped foreign layer f358be10862c: Skipped foreign layer 0d828dcd4895: Pushed 7305c5891baa: Pushed 7a83b9538cb1: Pushed 5437ac367abf: Pushed v1: digest: sha256:0aa9bfe03388e4fa20f83fcac99dafdf1933f58a2aed9d1c8bb2d05d162f062e size: 5343
iii. Azure Container Registry Repository: Pushed Image into Container Registry in Repositories
Conclusion:
These are the actions that can be performed on Container using Docker and how extensions are developed on Containers.