microsoft / navcontainerhelper

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

Question - API url version differs from installed media (beta vs v1.0) #1624

Closed ewaldventer closed 3 years ago

ewaldventer commented 3 years ago

Describe the issue I have a local BC docker container based on app version 16.1.12629.12805, and a UAT environment at the customer where the exact same version is installed from the installation media.

However, locally I can access the API using http://bc16:7048/BC/api/v1.0, but in the installed environment it is http://bc16:7048/BC/api/beta

Is there a config that I am missing? I just need to understand the reason for the difference in api version.

Scripts used to create container and cause the issue

$containerName = 'bc16'
$artifactUrl = Get-BcArtifactUrl -type 'OnPrem' -version '16.1.12629.12805' -country 'w1' -select 'Latest'
$licenseFile = 'C:\temp\partner.flf'
New-BcContainer `
    -accept_eula `
    -containerName $containerName `
    -credential $credential `
    -auth $auth `
    -artifactUrl $artifactUrl `
    -licenseFile $licenseFile `
    -memoryLimit 12G `
    -updateHosts

Full output of scripts

BcContainerHelper is version 1.0.19
BcContainerHelper is not running as administrator
Host is Microsoft Windows 10 Enterprise - 1909
Docker Client Version is 20.10.2
Docker Server Version is 20.10.2
Fetching all docker images
Using image mcr.microsoft.com/businesscentral:10.0.18363.1256
Creating Container bc16
Version: 16.1.12629.12805-w1
Style: onprem
Multitenant: No
Platform: 16.0.12630.12758
Generic Tag: 1.0.1.2
Container OS Version: 10.0.18363.1256 (1909)
Host OS Version: 10.0.18363.1316 (1909)
WARNING: Host OS and Base Image Container OS doesn't match, defaulting to hyperv. If you do not have Hyper-V installed or you encounter issues, you could try to specify -isolation process
Using hyperv isolation
Using locale en-US
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file C:\temp\braintree.flf
Files in C:\ProgramData\BcContainerHelper\Extensions\bc16\my:
- AdditionalOutput.ps1
- license.flf
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container bc16 from image mcr.microsoft.com/businesscentral:10.0.18363.1256
0ab56c07a1450b85981351e253f2d06033447fabbe83936ca6461258fc159c05
Waiting for container bc16 to be ready
Using artifactUrl https://bcartifacts.azureedge.net/onprem/16.1.12629.12805/w1
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files

Screenshots Container: image

PS C:\Users\Ewald.venter> Invoke-WebRequest -Method Get -Uri http://bc16:7048/BC/api/v1.0/ -Credential $credential

StatusCode        : 200
StatusDescription : OK
Content           : {"@odata.context":"http://bc16:7048/BC/api/v1.0/$metadata","value":[{"name":"companies","kind":"EntitySet","url":"companies"},{"name":"subscriptions","kind":"EntitySet","url":"subscription
                    s"},{"name":...
RawContent        : HTTP/1.1 200 OK
                    OData-Version: 4.0
                    Access-Control-Allow-Origin: *
                    Access-Control-Allow-Credentials: true
                    Access-Control-Expose-Headers: Date, Content-Length, Server, OData-Version
                    request-id: 8a5...
Forms             : {}
Headers           : {[OData-Version, 4.0], [Access-Control-Allow-Origin, *], [Access-Control-Allow-Credentials, true], [Access-Control-Expose-Headers, Date, Content-Length, Server, OData-Version]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 3761

UAT:

ServerInstance : MicrosoftDynamicsNavServer$BC
DisplayName    : Microsoft Dynamics 365 Business Central Server [BC]
State          : Running
ServiceAccount : HC\svc
Version        : 16.0.12630.12758
Default        : False

This is a secondary instance, so different port no. (they didn't want to use port sharing)

PS C:\Program Files\Microsoft Dynamics 365 Business Central\160\Service> Invoke-WebRequest -Method Get -Uri http://bc16:7058/BC/api/beta -Credential $cred

StatusCode        : 200
StatusDescription : OK
Content           : {"@odata.context":"http://bc16:7058/BC/api/beta/$metadata","value":[{"name":"companies","kind":"EntitySet","url":"companies"},{"name":"subscriptions","kind":"EntitySet","url":"s...
RawContent        : HTTP/1.1 200 OK
                    OData-Version: 4.0
                    Access-Control-Allow-Origin: *
                    Access-Control-Allow-Credentials: true
                    Access-Control-Expose-Headers: Date, Content-Length, Server, OData-Version
                    request-id: 3b2...
Forms             : {}
Headers           : {[OData-Version, 4.0], [Access-Control-Allow-Origin, *], [Access-Control-Allow-Credentials, true], [Access-Control-Expose-Headers, Date, Content-Length, Server, OData-Version]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : System.__ComObject
RawContentLength  : 3512

If I try to use API version no. v1.0

PS C:\Program Files\Microsoft Dynamics 365 Business Central\160\Service> Invoke-WebRequest -Method Get -Uri http://bc16:7058/BC/api/v1.0 -Credential $cred
Invoke-WebRequest : The remote server returned an error: (404) Not Found.
At line:1 char:1
+ Invoke-WebRequest -Method Get -Uri http://bc16:70 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Kind Regards,

Ewald

freddydk commented 3 years ago

The APIs comes in apps as far as I know. Look at which apps are installed in docker and you should find something like _ExcludeAPIV1 Not sure where the .app is on the dvd - but it should be there.

ewaldventer commented 3 years ago

Thank you!