Hi @Charles,
When you are sending chunked data to local azure function, it gives you 0 bytes because get_body() will work for chunked data only when deployed to Azure.
Firstly, below is the code which I used:
import azure.functions as func
import logging as rilg
import sys
chop = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@chop.route(route="http_trigger")
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
rilg.info('Hello Rithwik')
try:
rith_bdy = req.get_body()
rilg.info(f"Received {len(rith_bdy)} bytes")
body_text = rith_bdy.decode("utf-8")
return func.HttpResponse(f"Received {len(rith_bdy)} bytes\nData: {body_text}", status_code=200)
except Exception as cho:
rilg.error(f"Hello Rithwik, there is an error: {str(cho)}")
return func.HttpResponse(f"Error: {str(cho)}", status_code=500)
When calling local azure function, I too recieved 0 bytes as this is a known limitation that get_body() will work with chunked data only in Azure.
Deploying to Consumption Plan's Azure Function:
Firstly, created a function app in Consumption plan.
Now deployed the code to the function app created:
After Deploying, It worked even after adding Transfer Encoding : chunked
:
Please do not forget to click "Accept the answer” and Yes
wherever the information provided helps you, this can be beneficial to other community members.
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.