How to increase max file size in Azure App Service Windows (deployed through GitHub and using Java + Spring)

Eduardo Rocha 0 Reputation points
2024-06-26T11:53:22.0833333+00:00

So, i'm using GitHub to deploy my Java + Spring server to Azure App Service (Java 21, Windows). In Java side, i configured it to be able to receive up to 80MB files, however i'm getting 413 - PAYLOAD TOO LARGE when trying to upload a 35MB file.

I tried to upload a web.config file through Web App console on Azure Portal, but it crashed my app.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,962 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2024-06-27T06:26:38.8833333+00:00

    Eduardo Rocha, I understand you have tried multiple steps to isolate the issue and uploading web.config crashed your app.

    You may try increasing the default values for request headers size. You may add an AppSetting named JAVA_OPTS to your App Service with the value of -Dserver.max-http-header-size=30000 which will pass this to the JVM.

    Replace the 30000 (30KB) value of a value of your choice.

    User's image

    Also, just to highlight, The Front Ends that act as load balancers to the application(s) running behind them have a hard upper limit of 64KB for total request header sizes.

    If you haven't done, you may scale-up your WebApp and then test the following ( later, scale-down as required).

    You may navigate to Kudu console :

    1. Go to your KUDU console (https://<sitename>.scm.azurewebsites.net/debugconsole)
    2. Go to the “site” directory then the “wwwroot” directory.

    The default Request Limits value for the maxAllowedContentLength on IIS which is 30000000 (roughly 28.6MB). To modify this value, add the following to your web.config file.  

    <configuration>
       <system.webServer>
          <security>
             <requestFiltering>
                <requestLimits maxAllowedContentLength="<valueInBytes>"/>
             </requestFiltering>
          </security>
       </system.webServer>
    </configuration>
    
    
    

    Kindly let us know how it goes, I'll follow-up with you.


    If the answer helped (pointed, you in the right direction) > please click Accept Answer - it will benefit community members to find the answers quickly. 


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.