I am trying to run my python code in the azure function.
I want to run my code 24/7.
I have three files in my app folder
init.py
from .test import *
still getting an error in azure deploy
Exception while executing function: Functions.HttpTrigger1 <--- Result: Failure Exception: FileNotFoundError: [Errno 2] No such file or directory: 'HttpTrigger1\\setting_test.json' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 398, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 602, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper result = function(**args) File "/home/site/wwwroot/HttpTrigger1/__init__.py", line 21, in main test.run() File "/home/site/wwwroot/HttpTrigger1/test.py", line 191, in run config = read_setting() File "/home/site/wwwroot/HttpTrigger1/test.py", line 188, in read_setting with open('HttpTrigger1\setting_test.json') as json_file:
def main(req: func.HttpRequest) -> func.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:
test.run()
I calling my test.py file
there I have a file called setting_test.json to get data to run in the code.
def read_setting():
with open('setting_test.json') as json_file:
return json.load(json_file)
but the files were running in just like a python file but now it is not reading the given file
Python HTTP trigger function processed a request.
[2021-08-17T04:19:19.233Z] Executed 'Functions.HttpTrigger1' (Failed, Id=2ea68df6-4fd6-42be-a1b6-1016a02d49fa, Duration=72ms)
[2021-08-17T04:19:19.234Z] System.Private.CoreLib: Exception while executing function: Functions.HttpTrigger1. System.Private.CoreLib: Result: Failure
Exception: FileNotFoundError: [Errno 2] No such file or directory: 'setting_test.json'
Stack: File "C:\Users\HG\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 398, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "C:\Python39\lib\concurrent\futures\thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\HG\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 602, in _run_sync_func
return ExtensionManager.get_sync_invocation_wrapper(context,
File "C:\Users\HG\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\extension.py", line 215, in _raw_invocation_wrapper
result = function(**args)
File "F:\tradetest\bitfinexsupertrend\HttpTrigger1\__init__.py", line 21, in main
test.run()
File "F:\tradetest\bitfinexsupertrend\HttpTrigger1\test.py", line 192, in run
config = read_setting()
File "F:\tradetest\bitfinexsupertrend\HttpTrigger1\test.py", line 188, in read_setting
with open('setting_test.json') as json_file:
how do i get the data to the python test.py file to runn the code.