azure app service request size limit

Iheb Jandoubi 5 Reputation points
2024-05-01T20:24:54.3833333+00:00

Image

i have node js- express server deployed on azure app service .

in this application i am uploading file to azure blob storage through post request! locally for large files ( more than 30MiB) , the upload happens successfully , when i deployed my application , i always have request failed with status 413.

so how can i increase my request size ?

my application is deployed in azure app service

Reply

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

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 16,596 Reputation points
    2024-05-01T21:56:22.1566667+00:00

    Hi @Iheb Jandoubi To increase the request size limit for your Node.js Express application deployed on Azure App Service, you'll need to configure the server.maxRequestSize option in your Express app.

    First, locate the part of your code where you initialize the Express app. It usually looks like this:

    
    const express = require('express');
    
    const app = express();
    
    

    After that, you can set the server.maxRequestSize option to a larger value. For example, to set the limit to 100MB (104857600 bytes), you can add the following code:

    
    // Set maximum request size to 100MB
    
    app.use(express.json({ limit: '104857600' }));
    
    app.use(express.urlencoded({ limit: '104857600', extended: true }));
    
    

    This will set the request size limit for both JSON and URL-encoded payloads to 100MB.

    If you're using a different method to parse the request body, you'll need to adjust the code accordingly. For example, if you're using the multer middleware for file uploads, you can set the limits.fileSize option:

    
    const multer = require('multer');
    
    const upload = multer({
    
      limits: {
    
        fileSize: 104857600 // 100MB
    
      }
    
    });
    
    

    After making these changes in your code, redeploy your application to Azure App Service, and it should allow larger file uploads.

    Additionally, you can also increase the request size limit in Azure App Service by setting the web.maxRequestBodySizeInKb app setting in the Azure Portal or using the Azure CLI. This setting is applied at the server level and overrides any application-level settings.

    For example, to set the maximum request body size to 100MB (102400KB) using the Azure CLI, you can run the following command:

    
    az webapp config set --name <app-name> --resource-group <resource-group-name> --web-server-max-request-body-size-in-kb 102400
    
    

    you should replace <app-name> and <resource-group-name> with the appropriate values for your Azure App Service.

    By adjusting both the application-level and server-level settings, you should be able to upload larger files to your Node.js Express application deployed on Azure App Service.

    Best,

    Grace

    0 comments No comments