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.

2
  • You have referred to that SO answer already, and still want to create a 'folder' !? Commented Feb 15, 2023 at 13:35
  • yes, we don't work with files as much as we work with folder structure for migration purposes. Commented Feb 15, 2023 at 13:54

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.