microsoft / navcontainerhelper

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

Publish-BcContainerApp fails when app has a certain size #3260

Open CriticalMax opened 9 months ago

CriticalMax commented 9 months ago

Describe the issue When publishing our main app (65mb) to a cloud sandbox into dev scope we get an unexpected (and unspecific) error.

Scripts used to create container and cause the issue

$authContext = New-BcAuthContext `
    -clientID $entraApp.clientID `
    -clientSecret $entraApp.clientSecret `
    -tenantID $tenantId

Publish-BcContainerApp `
    -bcAuthContext $authcontext `
    -environment $environment `
    -appFile "$App" 

Full output of scripts

Attempting authentication to https://api.businesscentral.dynamics.com/.default u
sing clientCredentials...
Authenticated as app {guid}
Publishing {our_AppName} to https://api.businesscentral.dynamics
.com/v2.0/{our_environment}/dev/apps?SchemaUpdateMode=forcesync
Exception when calling "GetResult" with 0 argument(s): "Error sending the request. 
of the request."
Error sending the request.
The underlying connection was closed: Unknown error

Additional context We are using service to service auth, which you said wouldn't be possible in a comment under one of your blog posts but the app will still be published and installed despite the error message, it just takes around 10-15 minutes.

We created the app registration as shown in the guide (API.ReadWrite.All, Automation.ReadWrite.All, admin consent granted) and successfully added an entry in the business central entra applications page. Authentication works fine and all of our other apps (way smaller, around 100kb-25mb) don't run into this issue and get published/installed just fine.

Maybe I looked in the wrong places but I couldn't find limitations on the file size except for SOAP services (65,536 kilobytes) which seems to match our app but surely this isn't the problem at hand.

The error stems from the GetResult() method when sending the request to publish the app and I played around with the timeout and other httpHandler properties but that's where my research ended.

As a workaround I created a loop which checks every minute if the app is installed and while this works I would like to know if an app this large is the problem in general or if there really is some kind of problem either in the containerHelper or in Microsoft's handling of the request in the backend.

Do you know of any limitations regarding app file sizes when publishing to cloud environments or could this really be some sort of bug?

bernyd123 commented 6 months ago

Hi there,

I was just wondering if there are any feedback on this issue yet, as I have another partner that is experiencing the same issue as described above. Your feedback in this regard will be greatly appreciated.

Greetings, Berny During PTS - BC / MCT Companial

freddydk commented 6 months ago

Sorry, didn't see this issue - if possible, I would like to get my hands on an app, which causes this issue - then I can troubleshoot this. thanks

freddydk commented 5 months ago

I tried to make a repro here https://github.com/microsoft/bcsamples-bingmaps.pte/actions/runs/8153202748 - but that doesn't fail. Please create a repro scenario and provide me with an app and a script which which fails to upload using publish-bccontainerapp. Thanks

eclipses commented 5 months ago

Hi Freddy,

Facing this issue, please let me know where can I send you copy of the extensions to test it from your side.

Thank you Eclipses

freddydk commented 5 months ago

You can email a download link to freddyk at microsoft dot com and I will try to repro this.

freddydk commented 5 months ago

On this issue, I did get an app from @eclipses, which failed publishing. This was a simple out-of-memory exception though - 7Gb was allocated to the container and publishing the app required ~12Gb. I don't think this is problem from @CriticalMax or @bernyd123 - so if I am to investigate this - I still need something to reproduce this problem. Without a repro I can spend 100s of hours looking at code without ever finding the reason.

freddydk commented 5 months ago

@CriticalMax - on this

We are using service to service auth, which you said wouldn't be possible in a comment under one of your blog posts but the app will still be published and installed despite the error message, it just takes around 10-15 minutes.

When you publish using s2s - you will NOT publish into dev scope - it will publish into global (PTE) scope - just FYI (which you also can see on the URL (api.businessce....)

bernyd123 commented 3 months ago

Hi there Freddy,

Sorry this time it was me to miss the message... I will get the partner to reply to you on here.

Greetings, Berny