I think to have answered this question more than 20 times (live and on socials) but regularly it pops out, so I think that a quick post can help.
Dynamics 365 Business Central (SaaS and on-premises versions) has its own operational limits, limits imposed at platform level to ensure the availability and quality of Business Central services. You can see a list of the operational limits here.
One of the listed operational limits is related to the maximum file size that can be possible to upload on the Dynamics 365 Business Central server: the maximum size of files that can be uploaded to or downloaded from the service is by default = 350 MB.
But what happens sometimes when you upload a large file (for example a 50 MB file) on a Dynamics 365 Business Central on-premises instance? This file size is under the above limit, but you could receive the following error:
Because on Dynamics 365 Business Central on-premise there are two settings that you need to check:
- Dynamics 365 Business Central service tier setting
- IIS setting
In Dynamics 365 Business Central on-premises, in the CustomSettings.config file you have the ClientServicesMaxUploadSize setting:
<!-- Limits the size of files that can be uploaded in order to avoid out of memory errors. This value is in megabytes. --> <add key="ClientServicesMaxUploadSize" value="350"/>
Default is 350 MB but you can change it accordingly to your needs.
But this is not enough to handle large files! The second setting to check is at the IIS level (web server).
To check that, open IIS Manager, select your Dynamics 365 Business Central web server instance and click on Request Filtering:
When the Request Filtering pane displays, from the Actions pane on the right hand side of the screen click Edit Feature Settings. The Edit Request Filtering Settings window displays and here you can change the Maximum allowed content lenght (Bytes), setted as default to 30 MB:
When you change this value, please remember to restart the IIS instance.
Remember also that IIS has a limit of 4 GB (4294967295). Setting the value higher than 4 GB here will not remove that limit.
Thank you for the post.
Based on your information I wrote a psh script to align NST and IIS settings:
# Change onPrem max upload file size limit NST and IIS (max 2047 MB)
$bcinst = ‘BC’
$MaxUploadSizeMB = 300
Set-NAVServerConfiguration $bcinst -KeyName ClientServicesMaxUploadSize -KeyValue $MaxUploadSizeMB
Set-NAVServerInstance $bcinst -restart
$MaxUploadSizeBytes = $MaxUploadSizeMB * 1024 * 1024
$PSPath = “IIS:\Sites\Microsoft Dynamics 365 Business Central Web Client/$($bcinst)”
$FeatureFilter = ‘system.webServer/security/requestFiltering/requestLimits’
Set-WebConfigurationProperty -pspath $PSPath -filter $FeatureFilter -name ‘maxAllowedContentLength’ -value $MaxUploadSizeBytes
LikeLiked by 1 person
Thanks a lot for this.
Thank you, even after changing both properties, a csv file with 200mb doesn’t get imported. I tried XMLPort.run, UploadIntoStream, FileMgt.BLOBImportWithFilter. Nothing works on a 21.4. Any clue?
Have you correctly set the value in IIS? IIS instance was restarted?
Yes I have set Max allowed content lenght to 4147483647 Bytes and restarted several times. You will get the error if you try to import a file in Configuration Packages, it doesn’t matter which file it is as long as it has for example 135mb.