Working with Python Files in Azure Function - Read Only File System

别说谁变了你拦得住时间么 提交于 2021-01-28 14:49:50

问题


New to Azure functions, but looking to utilize a Function in an ADF pipeline to call out to a third party and write the json back for ingestion.

However, I receive 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') as file.

My script is below:

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}.")

Is there an Azure Function config that I'm missing?


回答1:


The current directory is indeed read-only. Use /tmp for temporary files (for example, open('/tmp/test.json', ...). For more details, see https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python#temporary-files.



来源:https://stackoverflow.com/questions/63094652/working-with-python-files-in-azure-function-read-only-file-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!