Azure function throwing request body too large(Microsoft.AspNetCore.Server.Kestral.Core) and unable to hit the function

JAPNAM SINGH 81 Reputation points
2021-07-12T14:34:33.173+00:00

I am having issues sending 200 mb file via form-data..I am getting the error Microsoft.AspNetCore.Server.Kestral.Core
Request body too large and unable to hit the function.

I added this in startup.cs as well
builder.Services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize =int.MaxValue;
});

still it gives me the same exception

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,237 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 68,396 Reputation points
    2021-07-13T11:36:56.43+00:00

    @JAPNAM SINGH Are you using HTTP trigger function app?
    As per the this code there is hard limit set for 100 MB and I don't see any configuration that can help you to increase this limit. I do see an issue created on the function host but as of now this is not configurable.

    The workaround would be :

    • We strongly recommend using blob storage to manage large uploads
    • The closest you can get is to switch to using a custom site extension (or for linux, with a custom container).

    The custom container approach is probably the most maintainable, because you could have your docker file modify the web.config and use the rest of the functions base image as it is. But every time there is a new functions image, you need to rebuilds your container and deploys.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Pierre-Luc Giguere 1,076 Reputation points
    2021-07-12T20:17:52.81+00:00

    Hi,

    This is nullable, I would try:

    builder.Services.Configure<KestrelServerOptions>(options =>
    {
    options.Limits.MaxRequestBodySize =null;
    });

    When set to null, the maximum request body size is unlimited.

    This looks like what you are looking for.

    Source: https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.core.kestrelserverlimits.maxrequestbodysize?view=aspnetcore-5.0

    0 comments No comments