Azure function returning HTTP code 202 while trying to Test/Run

I am new to azure functions and trying to schedule a python script through Azure Functions. The script is returing following response:

2021-10-08T12:15:00Z   [Information]   Executing 'Functions.quandldb_update' (Reason='Timer fired at 2021-10-08T12:15:00.0108672+00:00', Id=bf5b53e4-25ed-4d34-aa9e-ffeb91078470)
2021-10-08T12:15:00Z   [Verbose]   Sending invocation id:bf5b53e4-25ed-4d34-aa9e-ffeb91078470
2021-10-08T12:15:00Z   [Verbose]   Posting invocation id:bf5b53e4-25ed-4d34-aa9e-ffeb91078470 on workerId:835d8896-9373-4d72-bd44-dca2bc44a708
2021-10-08T12:15:00Z   [Error]   Executed 'Functions.quandldb_update' (Failed, Id=bf5b53e4-25ed-4d34-aa9e-ffeb91078470, Duration=24ms)

My Http Response Code is : 202 Accepted
And response body is empty

I am running the below code:

## Libraries needed ##
import quandl
import pandas as pd
import numpy as np
from sqlalchemy import create_engine
import azure.functions as func
def main(req: func.HttpRequest):
    pd.DataFrame(columns={"ABCD","EFGH"}).to_sql('mry_balance_sheet_test', con=engine, if_exists='append', chunksize=1000)

I have added pandas and other imports in requirements.txt

Please find below function.json:

{
  "scriptFile": "rawvalues_push.py",
  "bindings": [
    {
      "name": "mytimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */5 * * * *"
    }
  ]
}

I want to create/update table in my database by calling quandl api. The script is running fine locally on my system, please help me in creating azure function for the same

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If it is working fine in the local, then it should work after deploying the function as well.

Also, the code and functions.json looks good, So you missed to add local.settings.json in the portal Application settings as below:

Azure function returning HTTP code 202 while trying to Test/Run


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x