Reputation: 423
I have create azure function. In that function I have different folders in which some files exists. After deployment to azure portal, I cannot see any folder/directory in that function.
I am trying to write file in one of those folders. But when it try to write it, it throws exception "No such file or directory"
Here is my azure function structure:
When I try to access any of the folder like "./model_weights/teacher", it throws "No such file or directory" exception.
Here is the code:
How can i access any of the folder in azure function?
Upvotes: 3
Views: 3771
Reputation: 1864
The error traces to /home/site/wwwroot/
directory, to fix this, you can access root
directory using abspath
:
import os
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
You can refer to How To Access Azure Functions wwwroot Folder, How to access file in root directory in function app and Get root directory of Azure Function App v2
Upvotes: 2