How to fix Read-Only File system error [Errno30] when trying to use a python Azure Function to Write a dataframe to a blob in a storage account?

Mehul Makkar 5 Reputation points
2023-08-24T12:32:21.27+00:00

Hi
I have a python code that is reading a blob from azure storage account, transforming that excel file into a flat file, and uploading it back to the blob storage. I have deployed that code as an httptrigger azure function.
After the transformation, the code is uploading the file back to the storage account. I have run this code multiple times on my local system and validated that the file is getting generated and uploaded properly. However, when I deploy the code to the function app, it gives me this error : "An Error Occured : [Errno 30] Read-Only file system: 'Test12.xlsx'.

P.s Test12.xlsx is my output file name.

Could anyone please help me verify what might be going wrong with my process?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,674 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,141 questions
{count} vote

1 answer

Sort by: Most helpful
  1. navba-MSFT 27,500 Reputation points Microsoft Employee
    2023-08-25T07:06:08.5833333+00:00

    @Mehul Makkar Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I see that you are facing Read-Only file system error when trying to write a dataframe to a blob in an Azure storage account using a Python Azure Function.

    The error message indicates that the file system is read-only, could be due to many reasons.

    I understand that locally the same code is working fine as expected and the issue is only after deploying to Azure.

    To resolve this issue, you can check the following:

    • Plan 1:
      The function app file system is read only by default. To perform the Read/write on the storage, Could you please use the storage bindings ? Ensure that the output binding is configured correctly. The configuration needed for output binding is explained here.
    • Plan 2: Also ensure that the path exists. The path should be given in the format PATH/TO/BLOB. Example: containerName\mypath\Test12.xlsx . Could you please confirm if you have the right path within your function.json ? Refer the v2 and v2 samples here and here.
    • Plan 3: Please check this thread and see if that helps:
    • Plan 4: Are you making use of the temporary folder to write the processed date ? If yes, The tempfile.gettempdir() method returns a temporary folder, which on Linux is /tmp. Your application can use this directory to store temporary files that are generated and used by your functions when they're running. More Info here.
    • Plan 5: Are you trying to save the blob first and the after modifying it you are uploading it to storage ? Are you using blobService.get_blob_to_path ? Please check from the Azure portal if you have the WEBSITE_RUN_FROM_ZIP or WEBSITE_RUN_FROM_PACKAGE settings added within your Function App settings ? If yes, then your filesystem would be readonly. More info here and here.

    Hope this helps.

    If the above information doesn't help, Please share the sample code snippet, and steps to reproduce this issue. I will try to check at my end and see if I can reproduce this issue.

    Sharing some of the similar threads where the same issue was discussed: https://learn.microsoft.com/en-us/answers/questions/283950/azure-file-system-read-only-error-azure-function https://learn.microsoft.com/en-us/answers/questions/884340/read-only-file-system-error-in-azureml-studio https://stackoverflow.com/questions/63318567/azure-function-exception-oserror-errno-30-read-only-file-system https://www.appsloveworld.com/azure-functions/27/azure-function-apps-errno-30-read-only-file-system https://github.com/Azure/azure-functions-python-worker/issues/733 https://learn.microsoft.com/en-us/answers/questions/1002268/azure-functions-directory-read-only-on-linux

    **
    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

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.