Azure Function 中没有这样的文件或目录
No such a file or directory in Azure Function
我有创建天蓝色的功能。在该功能中,我有不同的文件夹,其中存在一些文件。部署到 Azure 门户后,我在该函数中看不到任何 folder/directory。
我正在尝试在其中一个文件夹中写入文件。但是当它尝试写入它时,它会抛出异常“没有这样的文件或目录”
这是我的 azure 函数结构:
当我尝试访问“./model_weights/teacher”之类的任何文件夹时,它抛出“没有这样的文件或目录”异常。
代码如下:
如何访问 azure 函数中的任何文件夹?
错误追溯到 /home/site/wwwroot/
目录,要解决此问题,您可以使用 abspath
:
访问 root
目录
import os
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
可以参考How To Access Azure Functions wwwroot Folder,如何在函数应用中访问根目录下的文件
和 Get root directory of Azure Function App v2
我有创建天蓝色的功能。在该功能中,我有不同的文件夹,其中存在一些文件。部署到 Azure 门户后,我在该函数中看不到任何 folder/directory。
我正在尝试在其中一个文件夹中写入文件。但是当它尝试写入它时,它会抛出异常“没有这样的文件或目录”
这是我的 azure 函数结构:
当我尝试访问“./model_weights/teacher”之类的任何文件夹时,它抛出“没有这样的文件或目录”异常。
代码如下:
如何访问 azure 函数中的任何文件夹?
错误追溯到 /home/site/wwwroot/
目录,要解决此问题,您可以使用 abspath
:
root
目录
import os
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
可以参考How To Access Azure Functions wwwroot Folder,如何在函数应用中访问根目录下的文件 和 Get root directory of Azure Function App v2