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

Mat*_*t P 7 python-3.x azure-functions

对 Azure 函数不熟悉,但希望利用 ADF 管道中的函数来调用第三方并将 json 写回以供摄取。

但是,我收到 Result: Failure Exception: OSError: [Errno 30] Read-only file system: ... "/home/site/wwwroot/AzureFunctionFileTest/ init .py ", line 10, in main with 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}.")
Run Code Online (Sandbox Code Playgroud)

我是否缺少 Azure Function 配置?

Ana*_*aev 9

当前目录确实是只读的。用于/tmp临时文件(例如,open('/tmp/test.json', ...)。有关更多详细信息,请参阅https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python#temporary-files