When you implement an Http Trigger Function that manages a request with a body, you have a size limit for the body itself. The default value for this limit is 100Mb (actually 104857600 bytes and you can read it in the Http Trigger documentation).
You can manage this limit using the Function App configuration. In particular, you can add the setting FUNCTIONS_REQUEST_BODY_SIZE_LIMIT
to set the maximum number of bytes you support in a single Http request.
Just to test how this setting works, use the following simple function:
[FunctionName("PostSomething")]
public IActionResult PostSomething(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "post")] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
return new OkResult();
}
You can do it also in your machine:
- Add the config to your local setting file of the Function project:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"FUNCTIONS_REQUEST_BODY_SIZE_LIMIT": 100
}
}
- Run the project:
- Make a POST Http request (for example using
curl
):
curl -X POST http://localhost:7077/api/post --data "This is the payload of the request and its size is more than 100 bytes. The function should throw an exception!!"
- The function's log should display the error related to the size of the body:
You can have the same behavior if you set the application setting value in a Function App on Azure:
and then you can test the function:
having the error:
Top comments (0)