The following two paths work well in singleton mode on my side:
1,
import logging
from pathlib import Path
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
path = str(Path.home()) + "/test.txt"
fileData = open(path, 'w+').write("testsomething")
return func.HttpResponse(
"create file with no problem."+path,
status_code=200
)
2,
import logging
import tempfile
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
path = tempfile.gettempdir() + "/test.txt"
fileData = open(path, 'w+').write("testsomething")
return func.HttpResponse(
"create file with no problem."+path,
status_code=200
)
This article says, Files written to the temporary directory aren't guaranteed to persist across invocations(Maybe your problem is similar, but not sure).
Your code seems to have nothing to do with multi-instance, but any way, this is not the recommended method. As user3732793 says in his answer, you can directly send data to storage blob without temporary file. Just retrieve a .xlsx file using an HTTP GET request and send data to blob storage by blob output binding or blob storage sdk.