1

I am trying to create a new folder inside of Azure http trigger folder, in order to receive some files from an API call and save them based on the name.

config_country_folder = context.function_directory+"/config/"+country.upper()
os.makedirs(config_country_folder, exist_ok=True)
logging.info('Config folder was added')

this part is inside the __init__.py of the trigger, and it's working locally.

however, once deployed and tested, the following error of code 500 occurred:

Result: Failure Exception: OSError: [Errno 38] Function not implemented: '/home/site/wwwroot/HttpTrigger1/config' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 452, 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 718, 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 33, in main os.makedirs(config_country_folder, exist_ok=True) File "/usr/local/lib/python3.9/os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/local/lib/python3.9/os.py", line 225, in makedirs mkdir(name, mode)

The issue is over the makedirs, and I went through the web, which they advised on using the context of the function to create folders. however the error occurred.

Also I was checking this link on using tempfile library, but this is not what I need here.

alim1990
  • 4,656
  • 12
  • 67
  • 130

1 Answers1

1

Create an azure Http trigger function in vs code. You can follow the below process.

Creating Httptrigger: We can create in our local with the python environment and select Http trigger enter image description here

Now go to init.py file and replace the code below to create a new folder Code:

import  os

def  main(req):
local_path = os.path.abspath(os.path.dirname(__file__))
function_path = os.path.abspath(os.path.join(local_path, ".."))
local_folder_path = os.path.join(local_path, "new_folder")
os.makedirs(local_folder_path, exist_ok=True)
function_folder_path = os.path.join(function_path, "new_folder")
os.makedirs(function_folder_path, exist_ok=True)
return  f"Created folders at {local_folder_path} and {function_folder_path}"

It worked in my local environment first.

And, Then deployed in azure function app.

enter image description here

This is my output from the above steps.

enter image description here

Jahnavi
  • 3,076
  • 1
  • 3
  • 10
vamsi
  • 156
  • 5