Hello.
Is it possible that you are running the function from a deployment package file and also trying to have a temp file created in the current working directory of that package?
In Azure, you can run your functions directly from a deployment package file in your function app. The other option is to deploy your files in the d:\home\site\wwwroot directory of your function app.
Run From Package makes wwwroot read-only, so you will receive an error when writing files to this directory.
You can turn that off by deleting the WEBSITE_RUN_FROM_ZIP or WEBSITE_RUN_FROM_PACKAGE application setting in the portal.
Sources:
https://stackoverflow.com/questions/53630773/how-to-disable-read-only-mode-in-azure-function-app (part #1)
https://learn.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package (troubleshoot part)