在Azure函数中使用Python文件-只读文件系统 [英] Working with Python Files in Azure Function - Read Only File System

查看:133
本文介绍了在Azure函数中使用Python文件-只读文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure函数的新功能,但希望利用ADF管道中的Function来调用第三方并写回json以进行提取.

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.

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

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.

我的脚本在下面:

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 Function配置?

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

推荐答案

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

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.

这篇关于在Azure函数中使用Python文件-只读文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆