Using tempfile package on Python. [Errno 1] Operation not permitted: '/tmp/tmpi95z5xb8'.

George Davis 1 Reputation point
2022-07-16T22:55:25.067+00:00

I am trying to use tempfile package on Python but the result is always Operation not permitted.

Result: Failure Exception: Exception: Err: [Errno 1] Operation not permitted: '/tmp/tmpi95z5xb8' Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 406, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 648, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper result = function(**args) File "/home/site/wwwroot/filestoragesecurity-azure-malwaretest/handler.py", line 312, in main raise Exception("Err: " + str(e))

GitHub - https://github.com/GeorgeDavis-TM/filestoragesecurity-azure-malwaretest/blob/main/filestoragesecurity-azure-malwaretest/handler.py

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-08-08T04:41:46.883+00:00

    Hi @George Davis ,

    Thanks for reaching out to Q&A forum.

    It appears that the handler.py script is performing write/zip operations on the temp directory. Azure functions being a sandboxed environment, prevents using other directories and its access might be restricted. I would suggest you to use the /home/site/wwwroot directory as this is a small capacity persistent storage which customers have full access.

    File system restrictions : https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#file-system-restrictionsconsiderations

    Feel free to reach out to me if you have any questions or concerns

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.