Showing posts with label Development. Show all posts
Showing posts with label Development. Show all posts

Saturday, August 15, 2020

Updating from NavContainerHelper to the new BcContainerHelper

 By Steve Endow

UPDATE: If you're interested in a convenient way to run the BcContainerHelper PowerShell commands, check out Krzysztof's Azure Data Studio Notebook with sample BcContainerHelper commands.  Jupyter Notebooks are a great way to include documentation and commands in a single convenient format.

On August 11, 2020, Freddy Kristiansen announced that he had released BcContainerHelper.

You can read his blog post here:

          https://freddysblog.com/2020/08/11/bccontainerhelper/

You will definitely want to read the entire blog post carefully, and perhaps read it a few times, as he shares quite a few important details about the new BcContainerHelper.

Same Great Container Helper, But Updated and Upgraded!


I made a video showing how I updated from NavContainerHelper to BcContainerHelper.  The process went flawlessly.


Here are the PowerShell Docker commands that I used to perform my update.

Sunday, August 9, 2020

Learning Business Central Development from Scratch Video Series

By Steve Endow

If you are new to Dynamics 365 Business Central development, join me on a journey to learn how to develop Business Central Extensions using VS Code and the AL language.

I have been developing business software for many, many years, but I am completely new to Business Central, AL, and VS Code.  And I am also new to Docker and PowerShell.  

Basically, I'm having to learn everything from scratch.  

I'm writing blog posts and making videos to share the learning resources I'm using and share my learning journey.

Tuesday, August 4, 2020

Business Central Download Symbols Error: No such host is known

By Steve Endow


UPDATE:  After researching this type of Windows hosts file name resolution issue, it seems there are dozens of possible reasons why the problem can occur.  I suspect my case was one of the simpler versions, and fortunately flushdns worked for me.  Here is a forum thread with examples of several rather odd causes and solutions.


This morning I tried to create a new Business Central AL project in VS Code.  I used AL Go! to create the project, set the server name in the launch.json file, and then tried to Download Symbols.

Very simple, very easy, right?

Nope.

No soup for you!

What? I performed these exact same steps 2 days ago on this same machine, and I was able to download symbols without any issues.

Here is the full video of the troubleshooting process:




I closed VS Code, relaunched it, created a new project, and tried again.  Same error.

Looking at the error log in VS Code, I saw "Error: No such host is known".  Say what?

Monday, August 3, 2020

Automatically Update NavContainerHelper - Improved Script

By Steve Endow

UPDATE: If you're interested in a convenient way to run the BcContainerHelper PowerShell commands, check out Krzysztof's Azure Data Studio Notebook with sample BcContainerHelper commands.  Jupyter Notebooks are a great way to include documentation and commands in a single convenient format.

I previously wrote about creating a simple scheduled task to automatically update NavContainerHelper.

While that simple script does work, it didn't have any logging or notification. I never knew when NavContainerHelper was updated.

I recently created a fancier PowerShell script to automatically build my Business Central Docker Containers every day, and while working on that script, I learned how to record elapsed time, log all activity, and send an email notification.

Based on that new learning, I wanted to upgrade the script that updates NavContainerHelper.

I wanted logging, elapsed time, and email notification if NavContainerHelper was updated to a new version.

Email notification when an update occurs


Here's what I came up with.  You'll need to adjust the file paths and email address, and generate your own email password file.

If you think of any other features the update could have, let me know!

 #v2.0 - August 1, 2020  
 #  
 $server = $env:COMPUTERNAME  
 #Define date values  
 $simpleDate = Get-Date -Format "M/d/yy"  
 $dateTime = Get-Date -Format "M/d/yy HH:mm"  
 $fileDateTime = Get-Date -Format "yyyy-MM-dd HHmm"  
   
 $body = ""  
 $message = ""  
 $updated = $false  
   
 #Specify file location for activity transcript log file  
 $transcriptFile = "D:\BCPowerShell\Logs\" + $fileDateTime + " " + $server + " NavContainerHelper Update Log.txt"  
   
 #Start recording transcript  
 Start-Transcript -Path $transcriptFile  
   
 #Record the start time  
 $StartTime = $(get-date)  
   
   
 #Define email configuration  
 $emailFrom = "email@gmail.com"  
 $emailTo = "email@gmail.com"  
 $smtpServer = "smtp.gmail.com"  
 $port = "587"  
 #Email password file created using: Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File -FilePath D:\BCPowerShell\Gmail.securestring  
 $passwordFile = "D:\BCPowerShell\Gmail.securestring"  
 $securePassword = ConvertTo-SecureString (Get-Content -Path $passwordFile)  
 $smtpCred = New-Object -TypeName PSCredential ($emailFrom, $securePassword)  
   
 $subject = $server + ": " + $simpleDate + " NavContainerHelper Update Log";  
   
 $started = "Start time: " + $StartTime  
 $body += $started + "`n`n"  
   
   
 #Define the module name  
 $moduleName = 'NavContainerHelper'  
   
 #Get currently installed version  
 $currentVersion = (Get-InstalledModule $moduleName).Version.ToString()  
 #Get the latest version available  
 $latestVersion = (Find-Module $moduleName).Version.ToString()  
   
   
   
 #If we don't have the latest version installed  
 If ($currentVersion -ne $latestVersion)  
 {  
   
   $message = "Current version: " + $currentVersion + "  Latest version: " + $latestVersion;  
   $message += "`n`nUpdating to version " + $latestVersion;  
   #Remove existing version(s)  
   Uninstall-Module $moduleName -Force -AllVersions  
   #Install latest version  
   Install-Module $moduleName -Force  
   
   $updated = $true;  
   
   #Verify version number  
   $currentVersion = (Get-InstalledModule $moduleName).Version.ToString()  
   $message += "`nUpdate complete";  
   $message += "`nCurrent version is now " + $currentVersion;  
       
   $body += "`n" + $message;  
   
   Write-Output $message  
 }  
 Else  
 {  
   #If we are on the latest version, log that info  
   $message = "You are on the latest version of " + $moduleName + ": " + $currentVersion;  
   Write-Output $message  
 }  
   
   
   
 #Record end time  
 $EndTime = $(get-date)  
 $output = "`nEnd time: " + $EndTime  
 $body += "`n" + $output   
 Write-Output $output   
   
 #Calculate elapsed time  
 $elapsedTime = $EndTime - $StartTime  
 $totalTime = "{0:HH:mm:ss}" -f ([datetime]$elapsedTime.Ticks)  
 $output = "Elapsed time: " + $totalTime  
 $body += "`n" + $output   
 Write-Output $output  
   
 $body += "`n`nFull log file is attached"   
   
 #Finish the transcript recording  
 #The Transcript must be stopped before trying to send the email,  
 #otherwise the log file will be locked, causing the email to fail  
 Stop-Transcript  
       
 if ($updated)  
 {  
 #Send the email  
 Send-MailMessage -From $emailFrom -To $emailTo `  
   -Subject $subject `  
   -Body $body `  
   -Attachments $transcriptFile `  
   -SmtpServer $smtpServer `  
   -Credential $smtpCred `  
   -Port $port `  
   -UseSsl  
 }  


Steve Endow is a Microsoft MVP in Los Angeles.  He works with Dynamics 365 Business Central, Microsoft Power Automate, Power Apps, Azure, .NET, Dynamics GP, and SQL Server.

You can also find him on Twitter and YouTube

https://www.precipioservices.com

Saturday, July 25, 2020

Fully automate the Business Central Container build process

By Steve Endow

I don't like maintenance tasks.  I don't like having to remember to do something on a regular basis.  I don't like having to do low value tasks constantly.

While it has been valuable for me to manually run NavContainerHelper the last several months, I think I am finally at a point where I sufficiently understand how it works and what it does.  I'm now ready to automate my Business Central Container build process so that I don't have to do it manually.

Just tell me how it went...

This isn't anything new--I'm just finally getting around to doing it for me with the features that I want.  If there are other ways or better ways to do this, let me know.

I share the background, my thinking, and my journey creating the script in this video.



In short, I've just wrapped the call to New-BcContainer in some additional PowerShell script to enable full logging, some basic error handling, and email notification.

Wednesday, July 22, 2020

Basic Business Central Docker Commands That I Use

By Steve Endow

On July 1, 2020, I made a video showing the basic Docker commands that I use to manage Business Central Docker Containers.

PowerShell isn't too bad

Here is a complete list of the commands that I've collected to manage Business Central Containers, as of July 2020.  If you have any others that you recommend, please comment below and let me know!


Thanks to Daniel and Tanya and D┼żoka for some additions!


   
 Open Powershell / Powershell ISE on HOST machine using Run As Administrator  
   
 
 NOTE: When referring to a Container ID or Image ID, you can use the first 
       few characters of the ID if they are unique--you do not have to always
       use the full ID.


 Check NavContainerHelper Version  
   
      Get-InstalledModule NavContainerHelper  
   
   
 Fresh Install of NavContainerHelper  
   
      Install-module navcontainerhelper  
      Import-Module navcontainerhelper  
   
   
 Install Latest NavContainerHelper  
   
 If you KNOW you don't have multiple versions installed:  
   
      Update-Module NavContainerHelper -Force  
   
 If you MIGHT have multiple versions installed:  
   
      $MyModuleName = <modulename>  
      Uninstall-Module $MyModuleName -allversions   
      Install-Module $MyModuleName
   
      NOTE: I do not recommend using the -Force option with Install-Module. 
            It can bypass valuable warnings that you want to know about.


 Alternate method to Remove Old Versions of NavContainerHelper  
   
      $ModuleName = 'navcontainerhelper';  
      $Latest = Get-InstalledModule $ModuleName;   
      Get-InstalledModule $ModuleName -AllVersions | ? {$_.Version -ne $Latest.Version} | Uninstall-Module -WhatIf  
   
   
   
 Container Management Commands  
   
   	Compact Container listing:
    
      docker ps --format "table {{.Names}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Status}}"
      
    Full listing:
    
      docker ps  
      docker ps -a  
        
      docker start <id>  
      docker stop <id>  
   
      
      docker container inspect 


 Remove Container  
   
    Recommended method:

      Remove-BCContainer <containername>


    Manual Docker method:

      docker stop <id> 
      docker rm <id> 
      Manually clean up hosts file
      Manually remove desktop icons
      Manually remove extensions from C:\ProgramData\NavContainerHelper\Extensions\
   

 Stop all running containers:  
        
      docker stop $(docker ps -aq)  
   
   
 Images  
   
       docker images  
       docker images -a  
   
 Remove Image  
   
      docker rmi <id>  
        
      docker rmi <repository>:<tag>  
   
   Remove all images:

      docker rmi $(docker images -aq)

   
 Clean up old images  
   
   Remove orphaned images with "< none >" identifiers:

      docker images -q -f dangling=true | % { docker rmi $_ }  


   Remove orphaned images:
   
   	  docker image prune -f
      
   Remove orphaned AND UNUSED images:
   
   WARNING: Be careful with this: It will remove generic OS images used by NavContainerHelper!

      docker image prune -a -f
   

   
 Get Artifact Info for an existing BC Container:  
   
      Get-BcContainerArtifactUrl containername  
        
      Get-NavContainerArtifactUrl containername  
   
   
 Diagnostics  
   
      Get-BcContainerEventLog  
   
   
   
 Create New BC Container  
   
      New-BcContainerWizard  
   
   
 https://blog.baudson.de/blog/stop-and-remove-all-docker-containers-and-images  
   




Steve Endow is a Microsoft MVP in Los Angeles.  He works with Dynamics 365 Business Central, Microsoft Power Automate, Power Apps, Azure, .NET, Dynamics GP, and SQL Server.

You can also find him on Twitter and YouTube

http://www.precipioservices.com

Saturday, January 25, 2020

Learning Dynamics 365 Business Central Development From Scratch: Introduction

By Steve Endow

If you've never done any NAV or Business Central development, but would like to, join me on this journey to learn how to develop in Dynamics 365 Business Central.

I've never used Dynamics NAV and don't even know what C/AL looks like.  I don't know what a "code unit" is.  Until a few months ago, I had never used Docker.  And although I've used Visual Studio for years, I don't really know how to use VS Code.  I know that Business Central uses a language called "AL", but I can't write a single line of AL.

Based on my experience so far trying to learn the Business Central application and Business Central AL development, I expect this will be a long journey for me.  Because I am still working mostly with Dynamics GP customers and projects in my day job, I have to learn Business Central in my "free time", so it isn't something I'll be able to pick up in just a few months.  A year ago, I gave myself 2 years to be "minimally competent" with the Business Central application and development.  Well, work gets busy and life gets busy, so I think I'm currently well behind on that 2 year timeline, and need to catch up.

Even though I have over 15 years of experience working with Dynamics GP and .NET and SQL Server, Business Central is a completely different world to me.  My fundamental knowledge of ERP software and software development is somewhat helpful as background, but it seems all of the specifics are completely different.  I want to learn Business Central and AL development and have the same comfort level that I have with Dynamics GP and .NET.  That will take time, and will require some pretty intensive learning.

So I'm starting from scratch.  Learning from scratch.  This is the start of that journey.


Why Business Central is Amazing #5: Community

 By Steve Endow The Business Central Community is amazing. Want proof?   Here's a great example from my Twitter timeline this afternoon:...