问题
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