1
votes

I am trying to post large file to azure functions which is written in visualstudio Code platform. when i tried to upload less than 28Mb, it was successful. beyond that i am getting exception Microsoft.AspNetCore.Server.Kestrel.Core: Request body too large. Tried using RequestSizeLimit, DisableRequestSizeLimit attributes, but no use. Following is the code written in VS code

public static async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req)
    {
            var provider = new MultipartMemoryStreamProvider();
            await req.Content.ReadAsMultipartAsync(provider);
            var file = provider.Contents.First();
            var fileInfo = file.Headers.ContentDisposition;
            var fileData = await file.ReadAsByteArrayAsync();
    }

And i am calling above function from angular6. I tried looking into the following doc and unable to implement in azure function [https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.kestrelserverlimits?view=aspnetcore-1.1][KestrelServerLimits Class] Please let me know if there is direct setting to allow large data or any other work around. Thanks in advance.

1
Not sure if this will work with Http Triggers, but it might point you in the right direction: github.com/aspnet/Announcements/issues/267 - Tobias Moe Thorstensen
I'd agree with Tobias here, probably better to upload to Azure Blob storage and process it from there. - DavidG
You need to upload your file to a Blob Storage Container and then you can create you function with a blob trigger instead of an http trigger. This way anytime a blob is created it will run your function. - Carlos Alves Jorge
@DavidG -- i am trying to upload file to blob storage using functions. we are trying for serverless architecture, so opted for azure functions. - charankumar
@CarlosAlvesJorge i am trying to upload file to blob storage using functions. we are trying for serverless architecture, so opted for azure functions. - charankumar

1 Answers

0
votes

Looking at this issue on GitHub, there's no way to get around the max size limit for Azure Functions (yet).

One workaround would be to cut your file into chunks and upload those to your API. You can then reassemble the file from the chunks. There are quite a few uploaders for Angular up on NPM