Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
335 stars 103 forks source link

POST with data greater then 100k fail with 40x errors #1198

Closed dk1010101 closed 1 year ago

dk1010101 commented 1 year ago

I originally raised this on the azure-functions-docker as this could be a Linux thing but equally it could be a azure fn python issue. See https://github.com/Azure/azure-functions-docker/issues/866. Apologies for cross-posting but i am not sure what the best place would be for this issue.

Basically, we have noticed that requests to (non-durable) azure python functions (running on premium p2v3) fail with 400 or 403 when the POST body size is greter than 100k (400 is the most common but 403s happen occasionaly). The called function body never gets executed. Running the same functions locally on windows using core tools works fine and as expected (ie it works up to 100M and then the caller throws). POST requests with body sizes of 100K or less work in all cases and never report 400s or 403s.

bhagyshricompany commented 1 year ago

Thanks for informing. You can try below options. Check the maximum request length setting in the host.json file. By default, the maximum request length is set to 100 MB. If this value is set lower, you may encounter issues with larger request bodies.

Check the timeout setting for your function. If the function takes too long to process the request, the server may terminate the connection and return a 400 or 403 error.

Check the Azure Function App's network configuration. If there are any firewalls or network security groups in place, they may be blocking requests with larger payloads.

Check if there are any restrictions on the size of requests that can be handled by the Python runtime environment in Azure Functions. you can refer some documents.

Host.json file documentation: https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json

Timeout documentation: https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout

Azure Function App networking documentation: https://docs.microsoft.com/en-us/azure/azure-functions/functions-networking-options

Azure Functions Python developer guide: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python if its not working then pls let me know.

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

dk1010101 commented 1 year ago

Thanks @bhagyshricompany I'll have a look and will report back.

dk1010101 commented 1 year ago

Apologies, i was away - Easter Hols. @bhagyshricompany - I don't know why this ticket had been marked as closed as it has not been resolved.

I looked at the suggestions above and here are my comments:

  1. hosts.json docs do not show how to change max request length. Needless to say, this was not changed in the hosts.json that is being used and is thus whatever Azure sets it to be. The same hosts.json runs happily locally under both windows azure functions and linux azure functions.
  2. Timeout settings are not an issue - the error is returned immediately. Functions with smaller payloads run happily for a lot longer
  3. I did not see any restrictions mentioned anywhere in Azure docs for python but Azure docs are not exactly easy to trawl through
  4. I had a look at the network settings around the Fn App and i did not see any size restrictions but i am happy to look for anything specific if you let me know what to look for. also this error happens when a function calls another function on the same function app server so networking impact would be minimum, i guess. Alternatively, is there some flag i can set somewhere to see where the call fails?

i had looked through all the links provided before posting the question and i had another look just in case. i also searched all the pages for the max size and related keywords with little success. I think this is something lower down which is why i asked here and any help/suggestions would be most appreciated.