@Jatinder Luthra Thanks for your patience on this.
Post making the below changes to the above shared code, I am able to execute the function from portal and from the data factory pipelines without any issues.
Removed this line text =req.params.get('name')
and updated this line : d = p.DataFrame({'Data': [name], 'Size': [len(name)]})
Here is the modified code:
import logging
import azure.functions as func
import pandas as p
from azure.functions import HttpRequest, HttpResponse
def main(req: HttpRequest) -> HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
d = p.DataFrame({'Data': [name], 'Size': [len(name)]})
res = d.to_json(orient='records')
print(res)
return func.HttpResponse(res, mimetype='application/json')
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
Here are the sample outputs for your reference.
- Output from Code+Test in portal.
- Output from ADF pipeline Azure Function activity:
Feel free to reach back to me if you have any further questions on this.