Azure函数 - 异常:OSError:[Errno 30] 只读文件系统:

9

我试图复制Excel文件中的值,但出现以下错误信息:

Exception while executing function: Functions.extract Result: Failure
Exception: OSError: [Errno 30] Read-only file system: './data_download/xxxxx.xlsx'
Stack:   File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 343, in handle_invocation_request
    call_result = await self._loop.run_in_executor(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 480, in __run_sync_func
    return func(**params)
  File "/home/site/wwwroot/extract/_init_.py", line 62, in main
    with open(download_file_path, "wb") as download_file:

我的代码

with open(download_file_path, "wb") as download_file:
3个回答

11

这与Azure函数无关,一般来说只有/tmp可写

尝试在文件路径中添加tmp

filepath = '/tmp/' + key

2
我相信Azure函数资源使用基于Linux的操作系统。所有文件都保存在/tmp文件夹中。
import tempfile
import os
   
local_path = tempfile.gettempdir()
filepath = os.path.join(local_path, filename)

然后您就可以将任何数据保存到filepath变量中了。


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接