The current directory is indeed read-only. Use /tmp
for temporary files (for example, open('/tmp/test.json', ...)
)
Below is the sample code for creating temporary files in temporary directory.
import logging
import azure.functions as func
import tempfile
from os import listdir
#---
tempFilePath = tempfile.gettempdir()
fp = tempfile.NamedTemporaryFile()
fp.write(b'Hello world!')
filesDirListInTemp = listdir(tempFilePath)

For complete information over temporary files refer this Document.
Here is the example code for importing Audio File in HTTP triggered function using Movie py.
import azure.functions as func
import azure.cognitiveservices.speech as speechsdk
import tempfile
import imageio
imageio.plugins.ffmpeg.download()
from moviepy.editor import AudioFileClip
speech_key="<speech service key>"
service_region="<speech service region>"
temp_file_path = tempfile.gettempdir() + "/result.wav"
text = 'hello, this is a test'
def main(req: func.HttpRequest) -> func.HttpResponse:
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
auto_detect_source_language_config = speechsdk.languageconfig.AutoDetectSourceLanguageConfig()
speech_synthesizer = speechsdk.SpeechSynthesizer(
speech_config=speech_config, auto_detect_source_language_config=auto_detect_source_language_config,audio_config=None)
result = speech_synthesizer.speak_text_async(text).get();
if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
stream = speechsdk.AudioDataStream(result)
stream.save_to_wav_file(temp_file_path)
myclip = AudioFileClip(temp_file_path)
return func.HttpResponse(str(myclip.duration))
Refer this SO thread for further details.