Accessing local storage from Linux Consumption App Function
Hey all,
I'm currently working on an Azure Function written in Python. Its job is to take a relatively small JSON payload, convert it to a table, and build an Excel file out of it, and send that file back as a bytes object through HTTP. (Pandas is about the only library I'm aware of that allows enough Excel customization to get the job done.)
In order to write the Excel file, I need to have at least a temp directory to write to. From what I've seen online, for Linux Consumption plans, /home should be a writable directory. However, I can't for the life of me write to it on my local environment or in the cloud-hosted, deployed version of the function.
Here's some simple example code, along with the error:
filepath = f"/home/{str(uuid.uuid4())}.xlsx"
with open(pd.ExcelWriter(filepath, date_format='YYYY-MM-DD', datetime_format='YYYY-MM-DD')) as excel_file:
#write operations
It's erroring on the open() line with the following text:
System.Private.CoreLib: Exception while executing function: Functions.CreateExcelFileFromAvailabilityData. System.Private.CoreLib: Result: Failure
Exception: FileNotFoundError: [Errno 2] No such file or directory: '/home/e96ecfe7-d509-425b-9c92-406690982eb6.xlsx'
Stack: File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 343, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "C:\Users\sejohnson\AppData\Local\Programs\Python\Python38\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 480, in __run_sync_func
return func(**params)
File "C:\Users\sejohnson\Repos\Griffis Business Intelligence\AvailabilityAndPricing\CreateExcelFileFromAvailabilityData\__init__.py", line 27, in main
with open(pd.ExcelWriter(filepath, date_format='YYYY-MM-DD', datetime_format='YYYY-MM-DD')) as excel_file:
What am I doing wrong?