microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
382 stars 246 forks source link

Error Creating a container with BCContainerHelper -- New-NavContainer.ps1:1828 Character:15 #2419

Closed MarcFB closed 2 years ago

MarcFB commented 2 years ago

Hello

I try to set up a container based development environment according to https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-running-container-development

I use the "BCContainerHelper" section:

everything as witten in the section.

When I execute the command, I get the following output

S C:\WINDOWS\system32> $artifactUrl = Get-BcArtifactUrl -type sandbox -country ch -select Latest New-BCContainer -accept_eula -containerName mysandbox -artifactUrl $artifactUrl BcContainerHelper is version 3.0.5 BcContainerHelper is running as administrator Host is Microsoft Windows 10 Pro - 21H1 Docker Client Version is 20.10.14 Docker Server Version is 20.10.14 Removing C:\ProgramData\BcContainerHelper\Extensions\mysandbox Downloading application artifact /sandbox/20.0.37253.39429/ch Downloading C:\Users\MarcX\AppData\Local\Temp\093359b1-c40c-4fa4-94f4-d90c02d22a60.zip Unpacking application artifact to tmp folder using 7zip Fetching all docker images Fetching all docker volumes INFO: Windows 10 21H1/21H2 images are not yet available, using 2004 as these are found to work better than 20H2 on 21H1/21H2 Pulling image mcr.microsoft.com/businesscentral:10.0.19041.1415 10.0.19041.1415: Pulling from businesscentral 295f12394c4f: Pulling fs layer 24b98dd3fbc4: Pulling fs layer 569a4c4f5ea8: Pulling fs layer 00dc665dbda6: Pulling fs layer dd978696e09a: Pulling fs layer ef2e14c0187f: Pulling fs layer 45eb88e308ea: Pulling fs layer 83c52bf61a50: Pulling fs layer 00dc665dbda6: Waiting dd978696e09a: Waiting ef2e14c0187f: Waiting 45eb88e308ea: Waiting da21618a42d6: Pulling fs layer aa6427e421e8: Pulling fs layer 33fae7d13c7b: Pulling fs layer 73285156abec: Pulling fs layer c93b4f5d1462: Pulling fs layer aa7385607a3f: Pulling fs layer da21618a42d6: Waiting 2b46fa27c65a: Pulling fs layer aa6427e421e8: Waiting 33fae7d13c7b: Waiting aa7385607a3f: Waiting c93b4f5d1462: Waiting 2b46fa27c65a: Waiting 83c52bf61a50: Waiting 569a4c4f5ea8: Verifying Checksum 569a4c4f5ea8: Download complete 00dc665dbda6: Verifying Checksum 00dc665dbda6: Download complete dd978696e09a: Verifying Checksum dd978696e09a: Download complete ef2e14c0187f: Verifying Checksum ef2e14c0187f: Download complete 45eb88e308ea: Verifying Checksum 45eb88e308ea: Download complete 83c52bf61a50: Verifying Checksum 83c52bf61a50: Download complete da21618a42d6: Verifying Checksum da21618a42d6: Download complete aa6427e421e8: Verifying Checksum aa6427e421e8: Download complete 24b98dd3fbc4: Verifying Checksum 24b98dd3fbc4: Download complete 73285156abec: Verifying Checksum 73285156abec: Download complete c93b4f5d1462: Verifying Checksum c93b4f5d1462: Download complete aa7385607a3f: Verifying Checksum aa7385607a3f: Download complete 2b46fa27c65a: Verifying Checksum 2b46fa27c65a: Download complete 33fae7d13c7b: Verifying Checksum 33fae7d13c7b: Download complete 295f12394c4f: Verifying Checksum 295f12394c4f: Download complete 295f12394c4f: Pull complete 24b98dd3fbc4: Pull complete 569a4c4f5ea8: Pull complete 00dc665dbda6: Pull complete dd978696e09a: Pull complete ef2e14c0187f: Pull complete 45eb88e308ea: Pull complete 83c52bf61a50: Pull complete da21618a42d6: Pull complete aa6427e421e8: Pull complete 33fae7d13c7b: Pull complete 73285156abec: Pull complete c93b4f5d1462: Pull complete aa7385607a3f: Pull complete 2b46fa27c65a: Pull complete Digest: sha256:5081759663a6e853232a99c2f7289d19e384ac148abe637e147d58739fc281e1 Status: Downloaded newer image for mcr.microsoft.com/businesscentral:10.0.19041.1415 mcr.microsoft.com/businesscentral:10.0.19041.1415 Using image mcr.microsoft.com/businesscentral:10.0.19041.1415 Creating Container mysandbox Style: sandbox Multitenant: Yes Version: 20.0.37253.39429 Platform: 20.0.37114.39316 Generic Tag: 1.0.2.1 Container OS Version: 10.0.19041.1415 (2004) Host OS Version: 10.0.19043.1645 (21H1) WARNING: Host OS is 21H1 and Container OS is 2004, defaulting to process isolation. If you experience problems, add -isolation hyperv. Using process isolation Using locale de-CH Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable) Files in C:\ProgramData\BcContainerHelper\Extensions\mysandbox\my:

I removed all the images and reinstalled docker, the result is the same (happends all the time).

What is wrong? BR Marc

freddydk commented 2 years ago

First thing I would try would be -isolation hyperv

MarcFB commented 2 years ago

unfortunately it gives the same error:

PS C:\WINDOWS\system32> $artifactUrl = Get-BcArtifactUrl -type sandbox -country ch -select Latest New-BCContainer -isolation hyperv -accept_eula -containerName mysandbox -artifactUrl $artifactUrl BcContainerHelper is version 3.0.5 BcContainerHelper is running as administrator Host is Microsoft Windows 10 Pro - 21H1 Docker Client Version is 20.10.14 Docker Server Version is 20.10.14 Removing C:\ProgramData\BcContainerHelper\Extensions\mysandbox Downloading application artifact /sandbox/20.0.37253.39459/ch Downloading C:\Users\MarcX\AppData\Local\Temp\e4ae8852-a2c7-4428-9a9b-e14a35f4c740.zip Unpacking application artifact to tmp folder using 7zip Downloading platform artifact /sandbox/20.0.37253.39459/platform Downloading C:\Users\MarcX\AppData\Local\Temp\d38139ff-1306-4466-8210-a20fedc010a3.zip Unpacking platform artifact to tmp folder using 7zip Downloading Prerequisite Components Downloading c:\bcartifacts.cache\sandbox\20.0.37253.39459\platform\Prerequisite Components\Open XML SDK 2.5 for Microsoft Office\OpenXMLSDKv25.msi Downloading c:\bcartifacts.cache\sandbox\20.0.37253.39459\platform\Prerequisite Components\IIS URL Rewrite Module\rewrite_2.0_rtw_x64.msi Downloading c:\bcartifacts.cache\sandbox\20.0.37253.39459\platform\Prerequisite Components\DotNetCore\DotNetCore.1.0.4_1.1.1-WindowsHosting.exe Fetching all docker images Fetching all docker volumes INFO: Windows 10 21H1/21H2 images are not yet available, using 2004 as these are found to work better than 20H2 on 21H1/21H2 Using image mcr.microsoft.com/businesscentral:10.0.19041.1415 Creating Container mysandbox Style: sandbox Multitenant: Yes Version: 20.0.37253.39459 Platform: 20.0.37114.39436 Generic Tag: 1.0.2.1 Container OS Version: 10.0.19041.1415 (2004) Host OS Version: 10.0.19043.1645 (21H1) Using hyperv isolation Using locale de-CH Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable) Files in C:\ProgramData\BcContainerHelper\Extensions\mysandbox\my:

freddydk commented 2 years ago

Then I think you should try this: https://freddysblog.com/2018/12/11/clean-up-after-yourself-docker-your-mom-isnt-here/ Which cleans up the docker filesystem (if there are cross linked files or like)

MarcFB commented 2 years ago

I did the "Reset To Factory defaults" you described and reinstalled everything. The error is still there :-(

As mentioned in the error description, I also tried to reinstall everything ... same problem.

freddydk commented 2 years ago

The blog post mentions running the docker zap script - did you do that?

MarcFB commented 2 years ago

No, it was not clear to me that this is still necessary. I'm running it now...

MarcFB commented 2 years ago

Next error:

PS C:\WINDOWS\system32> C:\Users\MarcX\Unbenannt5.ps1 Checking Docker Service Settings... This function will remove all containers, remove all images and clear the folder C:\ProgramData\Docker The function will also clear the contents of C:\ProgramData\BcContainerHelper. Are you absolutely sure you want to do this? (This cannot be undone) Type Yes to continue:Yes Running Docker System Prune Total reclaimed space: 0B Removing all containers (forced) Stopping Docker Service Downloading Docker-Ci-Zap Running Docker-Ci-Zap on C:\ProgramData\Docker Note: If this fails, please restart your computer and run this script again INFO: Zapped successfully Removing Docker-Ci-Zap Starting Docker Service Start-Service : Fehler beim Starten des Diensts "Docker Engine (docker)". In C:\Users\MarcX\Unbenannt5.ps1:66 Zeichen:1

And the Eventlog shows: fatal: unable to configure the Docker daemon with file C:\ProgramData\Docker\config\daemon.json: open C:\ProgramData\Docker\config\daemon.json: The system cannot find the path specified.

does the skrip remove something it needs to start the process?

freddydk commented 2 years ago

It should not - does a restart change anything?` else you will have to uninstall and reinstall again.

MarcFB commented 2 years ago

After a restart, the system seems to recreate the c:\programData\Docker folder and the subfolder/files. I reinstalled bccontainerhelper and the tried to reinstall the image:same result (same error message)

freddydk commented 2 years ago

same error message - like in hcsshim::PrepareLayer - failed failed in Win32: Incorrect function. (0x1) or hcsshim::CreateComputeSystem - The requested resource is in use.

The first one is typically due to incompatible OS between container and host. The second one have been seen quite a lot and typically is due to lack of memory or paging file too small (cleanup some times fixes this)

If you cannot make it work with this - my recommendation would be to upgrade to Windows 11

MarcFB commented 2 years ago

I managed to get around that error message. I terminated all services that are not essential (eg Chrome, Teams, ...) and then the process went on until it stopped with an error message when trying to start the container. Running this image on a Windows 10 installation seems to be very nitpicky! I'll try whether I can use a azure container (server image). Thanks for your help Br Marc

MarcFB commented 2 years ago

Sorry to bother you again but I also failed to make it work on azure :-( I tried exactly the steps as described here: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-get-started-container-sandbox

All I get ist the following error message from azure: "... The template deployment failed with error: 'The resource with id: '/subscriptions/d98a32aa-2c89-461e-a4c8-53bd2b5e84b6/resourceGroups/myNAVRG/providers/Microsoft.Compute/virtualMachines/test' failed validation with message: 'The requested size for resource '/subscriptions/d98a32aa-2c89-461e-a4c8-53bd2b5e84b6/resourceGroups/myNAVRG/providers/Microsoft.Compute/virtualMachines/test' is currently not available in location 'switzerlandnorth' zones '' for subscription 'd98a32aa-2c89-461e-a4c8-53bd2b5e84b6'. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details.'.'. (Code: InvalidTemplateDeployment) .."

It's really frustrating that nothing works - not even the basic examples that MS provides :-( Did you ever manage to bring one of those sandbox examples up and running?

MarcFB commented 2 years ago

To give you some more details:

{"code":"InvalidTemplateDeployment","message":"The template deployment failed with error: 'The resource with id: '/subscriptions/d98a32aa-2c89-461e-a4c8-53bd2b5e84b6/resourceGroups/myNAVRG/providers/Microsoft.Compute/virtualMachines/test' failed validation with message: 'The requested size for resource '/subscriptions/d98a32aa-2c89-461e-a4c8-53bd2b5e84b6/resourceGroups/myNAVRG/providers/Microsoft.Compute/virtualMachines/test' is currently not available in location 'switzerlandnorth' zones '' for subscription 'd98a32aa-2c89-461e-a4c8-53bd2b5e84b6'. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details.'.'."}

I tried different regions, the result is always the same

freddydk commented 2 years ago

The error states that the requested size is not available in switzerlandnorth. You can try a different datacenter or see which sizes are available in the URL provided in the error. I typically use North Europe or West Europe and have never seen these problems.

freddydk commented 2 years ago

Have you tried creating just a simple VM to see whether your subscription allows you to add a VM?

MarcFB commented 2 years ago

I tried to create a VM in the azure web interface and it seems that I can do it in "westeurope".

Using "westeurope" in the BC skript leads to the same error:

{"code":"InvalidTemplateDeployment","message":"The template deployment failed with error: 'The resource with id: '/subscriptions/d98a32aa-2c89-461e-a4c8-53bd2b5e84b6/resourceGroups/BC_Competec/providers/Microsoft.Compute/virtualMachines/bc_competec' failed validation with message: 'The requested size for resource '/subscriptions/d98a32aa-2c89-461e-a4c8-53bd2b5e84b6/resourceGroups/BC_Competec/providers/Microsoft.Compute/virtualMachines/bc_competec' is currently not available in location 'westeurope' zones '' for subscription 'd98a32aa-2c89-461e-a4c8-53bd2b5e84b6'. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details.'.'."}

I tried to ge a list of the valid VMs with az vm list-skus --location westeurope --output table

and there are quite some available VMs. But there is no match between the available VMs in azure and the VMs I can choose in the skript:

image

MarcFB commented 2 years ago

Setting up a VM with the web interface works image

freddydk commented 2 years ago

Very strange - it seems like you are missing a number of images???? When I run your az account - it looks like this: image

Is there anything special with that subscription?

I will see if I can make the list in the ARM template more dynamic - or in other ways allow people to specify other sizes.

freddydk commented 2 years ago

I have updated the available sizes in the ARM templates (https://aka.ms/getbc). In your list - you only had the DC VMs (confidential = more expensive) or the AMD based VMs v5 (Dxxas_v5) The DC VMs won't be in the list - I have added _v4 and _v5 (including now AMD based VMs as well)

freddydk commented 2 years ago

Did you manage to make this work?

MarcFB commented 2 years ago

Hi Freddy Not yet! I had a week holidays 😊

Right now I try to bring an docker image on a Windows Server 19 up and running. I managed to install the image but I did not manage to connect Visual Studio Code There are always billions of questions and even more errors and problems ☹

For example: Visual Studio Code says [2022-05-11 13:39:29.92] Using reference symbols cache path: c:\Users\mkt1\Documents\AL\BCTest./.alpackages [2022-05-11 13:39:29.92] Sending request to http://bc-mk:8080/BC/dev/metadata?tenant=default [2022-05-11 13:39:30.58] The request for path /BC/dev/metadata?tenant=default failed with code NotFound. Reason: Not Found [2022-05-11 13:39:30.58] Sending request to http://bc-mk:8080/BC/dev/webendpoint [2022-05-11 13:39:30.58] The request for path /BC/dev/webendpoint failed with code NotFound. Reason: Not Found [2022-05-11 13:39:30.58] Sending request to http://bc-mk:8080/BC/dev/metadata?tenant=default [2022-05-11 13:39:30.58] The request for path /BC/dev/metadata?tenant=default failed with code NotFound. Reason: Not Found [2022-05-11 13:39:30.58] Sending request to http://bc-mk:8080/BC/dev/webendpoint [2022-05-11 13:39:30.58] The request for path /BC/dev/webendpoint failed with code NotFound. Reason: Not Found

When I try to download symbols. What’s wrong? In you blog https://freddysblog.com/2019/08/20/business-central-on-docker-for-non-experts/ You describe that with the option -includeAL is helpful when I want to do customizations. Guess what happens when I add that switch to New-BCContainer?

-includeAL : The term '-includeAL' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:42 char:3

I also have no idea how I can access the BC administration (e.g for switching to SSL)

It’s all broken, untested, outdated, …

Von: Freddy Kristiansen @.> Gesendet: Mittwoch, 11. Mai 2022 06:40 An: microsoft/navcontainerhelper @.> Cc: Marc Knaff @.>; Author @.> Betreff: Re: [microsoft/navcontainerhelper] Error Creating a container with BCContainerHelper -- New-NavContainer.ps1:1828 Character:15 (Issue #2419)

Did you manage to make this work?

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/navcontainerhelper/issues/2419#issuecomment-1123179216, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALHUPI4QUKONSYFSGAYA44TVJM22FANCNFSM5T7TILAA. You are receiving this because you authored the thread.Message ID: @.**@.>>

freddydk commented 2 years ago

it looks like you added a new line with -includeAL without adding a ` character to end the preceding line - that causes powershell to do what you describe. -includeAL is only really used for code customized base apps, I don't think you are going there.

I know it is tedious, but you should in every comment include the full script and the full output of that, that makes it much easier to help.

Also - in VS Code - what is the output of launch.json ? Looks like you have set the port to 8080 - that is likely not correct.

MarcFB commented 2 years ago

You are right, I forgot the ‘ in the script ☹ Now I tried without port and got an authentication error (similar to https://github.com/microsoft/AL/issues/6273)

But let’s start with the dodumentation:

I use the following script:

$accept_eula = $true $containername = 'MKBC2022' $licenseFile = '' $auth = 'Windows' $usessl = $false $updateHosts = $true $assignPremiumPlan = $true $shortcuts = 'Desktop'

$artifactUrl = Get-BcArtifactUrl -country 'CH' -select 'Latest'

if ($auth -eq 'Windows') { $credential = get-credential -UserName $env:USERNAME -Message 'Using Windows Authentication. Please enter your Windows credentials.' } elseif ($auth -eq 'UserPassword') { $credential = get-credential -Message 'Using Username/Password Authentication. Please enter credentials.' } else { throw '$auth needs to be either Windows or UserPassword' }

if (!$accept_eula) { throw 'You have to accept the eula in order to create a Container.' } if (!($containername)) { throw 'You have to specify a container name in order to create a container.' } if (!($artifactUrl)) { throw 'No matching build was found for your version of Business Central' } New-BcContainer -accept_eula:$accept_eula -containername $containername -artifactUrl $artifactUrl -auth $auth -Credential $credential -usessl:$usessl -updateHosts:$updateHosts -licenseFile $licenseFile -assignPremiumPlan:$assignPremiumPlan ` -shortcuts $shortcuts

if ($licenseFile) { Setup-BcContainerTestUsers -containerName $containername -password $credential.Password }

This is the output

BcContainerHelper is version 3.0.7 BcContainerHelper is running as administrator Hyper-V is Disabled Host is Microsoft Windows Server 2019 Standard - ltsc2019 Docker Client Version is 20.10.9 Docker Server Version is 20.10.9 Downloading application artifact /sandbox/20.1.39764.40432/ch Downloading C:\Users\mkt1\AppData\Local\Temp\2\47149270-f527-4486-ae38-f90f8a6df826.zip Unpacking application artifact to tmp folder using Expand-Archive Downloading platform artifact /sandbox/20.1.39764.40432/platform Downloading C:\Users\mkt1\AppData\Local\Temp\2\ec59ae5d-7414-4d6a-a1f2-5b4f5301efb9.zip Unpacking platform artifact to tmp folder using Expand-Archive Downloading Prerequisite Components Downloading c:\bcartifacts.cache\sandbox\20.1.39764.40432\platform\Prerequisite Components\Open XML SDK 2.5 for Microsoft Office\OpenXMLSDKv25.msi Downloading c:\bcartifacts.cache\sandbox\20.1.39764.40432\platform\Prerequisite Components\IIS URL Rewrite Module\rewrite_2.0_rtw_x64.msi Downloading c:\bcartifacts.cache\sandbox\20.1.39764.40432\platform\Prerequisite Components\DotNetCore\DotNetCore.1.0.4_1.1.1-WindowsHosting.exe Fetching all docker images Fetching all docker volumes Using image mcr.microsoft.com/businesscentral:10.0.17763.973 Creating Container MKBC2022 Style: sandbox Multitenant: Yes Version: 20.1.39764.40432 Platform: 20.0.39668.40349 Generic Tag: 1.0.2.1 Container OS Version: 10.0.17763.973 (ltsc2019) Host OS Version: 10.0.17763.973 (ltsc2019) Using process isolation Using locale de-CH Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable) Files in C:\ProgramData\BcContainerHelper\Extensions\MKBC2022\my:

Files: http://MKBC2022:8080/ALLanguage.vsix

WARNING: You are running a container which is 535 days old. Microsoft recommends that you always run the latest version of our containers.

Container Total Physical Memory is 16.0Gb Container Free Physical Memory is 8.9Gb

Initialization took 39 seconds Ready for connections! Reading CustomSettings.config from MKBC2022 Creating Desktop Shortcuts for MKBC2022 Container MKBC2022 successfully created

Use: Get-BcContainerEventLog -containerName MKBC2022 to retrieve a snapshot of the event log from the container Get-BcContainerDebugInfo -containerName MKBC2022 to get debug information about the container Enter-BcContainer -containerName MKBC2022 to open a PowerShell prompt inside the container Remove-BcContainer -containerName MKBC2022 to remove the container again docker logs MKBC2022 to retrieve information about URL's again

My Visual Studio Code looks like

@.***

And you see the output in the “Output” section I can access BC with the link http://mkbc2022/BC/?tenant=default

And this is how the user looks: @.***

Do you have any idea, what’s the problem now? BR Marc

Von: Freddy Kristiansen @.> Gesendet: Mittwoch, 11. Mai 2022 14:49 An: microsoft/navcontainerhelper @.> Cc: Marc Knaff @.>; Author @.> Betreff: Re: [microsoft/navcontainerhelper] Error Creating a container with BCContainerHelper -- New-NavContainer.ps1:1828 Character:15 (Issue #2419)

it looks like you added a new line with -includeAL without adding a ` character to end the preceding line - that causes powershell to do what you describe. -includeAL is only really used for code customized base apps, I don't think you are going there.

I know it is tedious, but you should in every comment include the full script and the full output of that, that makes it much easier to help.

Also - in VS Code - what is the output of launch.json ? Looks like you have set the port to 8080 - that is likely not correct.

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/navcontainerhelper/issues/2419#issuecomment-1123718209, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALHUPI6BSUX5BE4XTBBCT7LVJOUEHANCNFSM5T7TILAA. You are receiving this because you authored the thread.Message ID: @.**@.>>

freddydk commented 2 years ago

I am sorry, but I cannot see the images you sent in the email . Could you add them to github?

MarcFB commented 2 years ago

No problem :-)

Visual Studio Code: image

User Card in BC image

freddydk commented 2 years ago

You container is setup with Windows authentication. in launch.json you have specified UserPassword authentication.

Either recreate your container with userpassword - or change to Windows in launch.json Note for Windows Auth to work - the container needs to be started with your Windows credentials Lastly windows Auth. is known to cause problems - i always recommend userpassword, but since the webclient works - you are probably good.

freddydk commented 2 years ago

Did you manage to make this work?

MarcFB commented 2 years ago

Hi Freddy Yes, I was able to make it work. The problem was - like you supposed - the different authentication methods. Since I used the script which is provided on the "sandox environment" page in BC, I did not pay attention to this.

I also was able to set up a Azure Virtual Machine with the new scrip you provided (let's say the new bvirtual machines you added). I found a match in region europewest.

So finally I have my sandbox :-)

Thank you for your help BR Marc