'azure function is not working in azure cloud but working in local. giving error in python script
import datetime
from distutils.log import log
import logging
import os
import azure.functions as func
def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
# os.system('echo "change directory to propertyscraper project"')
# os.system('cd ./propertyscraper')
# ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
os.system('echo "*****************************************************"')
logging.info(os.getcwd())
# os.system("echo $PWD")
logging.info(f"curret dir: {os.getcwd()}" )
os.system('echo "run airbnb spider"')
path = os.path.join("scraped_json_files","airbnb.json")
os.system(f"scrapy crawl airbnb -o {path}")
logging.info(f"current dir files:{os.listdir()}")
logging.info(f"previous dir files: {os.listdir('..')}")
file_creation_time = datetime.datetime.now().strftime(f'%Y-%m-%d_%H-%M-%S')
new_file_path = os.path.join("scraped_json_files","airbnb"+file_creation_time+".json")
# os.rename(path, f"./scraped_json_files/airbnb{file_creation_time}.json")
os.rename(path,new_file_path)
# os.rename("./scraped_json_files/airbnb.json", "scraped_json_files/airbnb_"+file_creation_time+".json")
below is the error while I am running the azure function in azure. above code is working in my local system which is windows 10 but giving below error in azure. please help what am I doing wrong
Result: Failure Exception: OSError: [Errno 38] Function not implemented: 'scraped_json_files/airbnb.json' ->
'scraped_json_files/airbnb2022-04-18_09-03-46.json' Stack: File
"/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py"
, line 402, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, 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 611, 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/scraper_timer_trigger/__init__.py", line 32, in main os.rename(path,new_file_path)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|