Python 3.x 在Azure Function-只读文件系统中使用Python文件

Python 3.x 在Azure Function-只读文件系统中使用Python文件,python-3.x,azure-functions,Python 3.x,Azure Functions,Azure函数是新手,但希望利用ADF管道中的函数调用第三方并将json写回以供接收 但是,我收到结果:失败异常:OSError:[Errno 30]只读文件系统: ... “/home/site/wwwroot/AzureFunctionFileTest/init.py”,第10行,以open('test.json','w')作为文件 我的脚本如下: logging.info('Python HTTP trigger function processed a request.') loggi

Azure函数是新手,但希望利用ADF管道中的函数调用第三方并将json写回以供接收

但是,我收到结果:失败异常:OSError:[Errno 30]只读文件系统: ... “/home/site/wwwroot/AzureFunctionFileTest/init.py”,第10行,以open('test.json','w')作为文件

我的脚本如下:

logging.info('Python HTTP trigger function processed a request.')

logging.info('opening file')

with open('test.json', 'rb') as file:
    logging.info('creating data')
    data = "Hello world"
    logging.info('writing file')
    file.write(data)

return func.HttpResponse(f"This HTTP triggered function executed successfully with {data}.")

是否缺少Azure函数配置?

当前目录确实是只读的。对临时文件使用
/tmp
(例如,
open('/tmp/test.json',…)
。有关更多详细信息,请参阅。

世界上所有的搜索,我都找不到您链接的那篇文章。这非常有帮助。我假设如果使用数据帧,我也可以使用tempfile.NamedTemporaryFile作为temp:df.to_csv(temp.name,…)然后上传到blob?@MattPieper是的,
tempfile.NamedTemporaryFile
也应该可以工作。请注意:/tmp似乎是(根据经验-找不到文档)一个tmpfs,因此您正在写入内存,如果写入的数据量很大,可能会导致内存压力。