HodorNV / ALOps-External-Deployer

Enables external deployment in Microsoft Business Central (API Deploy)
3 stars 1 forks source link

Is it possible to install External Deployer in a container? #1

Closed nicolassaleron closed 3 years ago

nicolassaleron commented 3 years ago

Hello,

I am asking this if by any chance you have the solution: I would like using ALOps.ExternalDeployer with a Business Central in a Docker container (created with New-BcContainer from BCContainerHelper). And I am stuck because apparently the container rejects the connection on port 7040...

This is the script I run against the container after it has been created:

Invoke-ScriptInBCContainer -containerName bc170 -scriptblock {
    Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
    Install-Module ALOps.ExternalDeployer
    Import-Module ALOps.ExternalDeployer
    New-ALOpsExternalDeployer -ServerInstance 'BC'
}

I publish an app with the command below (it works if BC is not installed in Docker). Previous calls to APIs work because I am able to get the companyId.

Invoke-RestMethod -Method Patch `
    -Uri "$APIBaseURL/companies($companyId)/extensionUpload(0)/content" `
    -Credential $credential `
    -ContentType "application/octet-stream" `
    -Headers @{"If-Match" = "*" } `
    -InFile $AppToDeploy | Out-Null

After that I call this command to get the deployment status:

Invoke-RestMethod -Method Get `
    -Uri "$APIBaseURL/companies($companyId)/extensionDeploymentStatus" `
    -Credential $credential

The output is strange because the status is Unknown instead of Completed or Failed:

2020-10-20T16:51:34.2887875Z @odata.etag   : W/"JzQ0O1E2VlVOYWk0MEMwV2NlVjVTM1JLeUVYMFdLU0R0dUdEMEsydnlnTHEweTA9MTswMDsn"
2020-10-20T16:51:34.2889824Z operationID   : 2825b0e2-6958-4f97-9f79-21108bb33385
2020-10-20T16:51:34.2894516Z name          : MyAppName
2020-10-20T16:51:34.2899841Z publisher     : MyAppPublisher
2020-10-20T16:51:34.2902573Z operationType : Upload
2020-10-20T16:51:34.2904204Z status        : Unknown
2020-10-20T16:51:34.2905403Z schedule      : Immediate
2020-10-20T16:51:34.2907426Z appVersion    : 17.0.0.3102
2020-10-20T16:51:34.2910086Z startedOn     : 2020-10-20T16:51:33.66Z

When I look into the Windows logs of the container, the following error is raised by the NST:

The description for Event ID 701 from source MicrosoftDynamicsNavServer$BC cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event: 

Server instance: BC
Category: Extensions
ClientSessionId: 88c273a7-44f3-4100-b8cf-e5204925c932
ClientActivityId: 7b747555-7584-49b0-a93e-e99e50137766
ServerSessionUniqueId: f069c25f-29ac-485b-b56a-6c6d5c5765ed
ServerActivityId: 419e491e-b48f-4c70-879f-54eaee5266d3
EventTime: 10/20/2020 16:20:49
Message Proxy Service Deployment Failure -- Unexpected Exception; Error:An error occurred while sending the request.; InnerException:   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dynamics.Nav.ExtensionProxySvc.Client.Core.ProxyServiceHttpClient.<>c__DisplayClass8_0.<<InvokeSendRequest>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Dynamics.Nav.ExtensionProxySvc.Client.Util.TaskHelper.<>c__DisplayClass1_0`1.<<InvokeAsyncOperation>b__0>d.MoveNext(); StackTrace:System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:7040
   at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
ProcessId: 6724
Tag: 00001XR
ThreadId: 117
CounterInformation: 
CustomParameters: {
}
GatewayCorrelationId: 
nicolassaleron commented 3 years ago

Found my issue, I have forgotten to Install-ALOpsExternalDeployer :p