简体   繁体   中英

Azure function (out of process) HTTP Trigger Post request Data limitation

This is an issue with Azure functions 4x (out of process)

I am trying to Post a data that is more than 4 MB (4096 Bytes) to the Azure function using HTTP Trigger.

It is timing out. Following is my code in Azure function

[Function("HttpTriggerCSharp")]
        public async Task<HttpResponseData> HttpTriggerCSharp(
                [HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req,

                FunctionContext executionContext)
        {
            
            HttpResponseData response = HttpResponseData.CreateResponse(req);

            string requestBody = String.Empty;
            using (StreamReader streamReader = new StreamReader(req.Body))
            {
                requestBody = await streamReader.ReadToEndAsync();
            }

            return response;

        }

I am using Postman as client with following configuration:

Postman configuration

The test file of 4 MB

I checked the Microsoft doc https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=csharp

It refers to 100 MB limitation. Please let me know, what mistake I am doing?

The above functionality works with Azure functions in-process (3x).

The Azure Function v4 is in Preview Mode and is not fully supported and approved for the production use . Moreover it only support the latest versions of .NET, Javascript and Java. Check this language support for more information.

We can't directly migrate from Azure Function 3.x to 4.x because other app setting changes and changes to your function code may be required.

Check this for more infromation How to target Azure Functions runtime versions .

To solve this problem try migrating the function app from 3.x to 4.x. To migrate function from 3.x to 4.x, follow the following two steps:

  1. Set the FUNCTIONS_EXTENSION_VERSION application setting to ~4 with the following Azure CLI command:

     az functionapp config appsettings set --settings FUNCTIONS_EXTENSION_VERSION=~4 -n <APP_NAME> -g <RESOURCE_GROUP_NAME>
  2. For Windows function apps, the runtime requires .NET 6.0 to be enabled with the following Azure CLI command:

     az functionapp config set -.net-framework-version v6.0 -n <APP_NAME> -g <RESOURCE_GROUP_NAME>

Note that Azure Functions 4.x enforces minimum version requirements for extensions. And Azure Functions 4.x requires the Microsoft.NET.Sdk.Functions extension be at least 4.0.0 .

Regardless of the function app timeout setting, 230 seconds is the maximum amount of time that an HTTP triggered function can take to respond to a request. If it exceeds this you get a timeout error.

Check this Function app timeout duration documentation for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM