az webapp config storage-account Mounted as read only?

Laron Walker 21 Reputation points

I've mounted a share to my python function app using the az webapp config storage-account command. When i try to write fiiles, i get this error

Result: Failure Exception: OSError: [Errno 30] Read-only file system: 'model/weights.pickle' Stack: File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/",

in my code, i'm using the following code to write files.

 with open(model_similarity_path+'weights.pickle', 'wb') as handle:
            pickle.dump(model_similarity, handle, protocol=pickle.HIGHEST_PROTOCOL)

is there something that i need to do in order to mount the share as read/write? I'm able to read files just fine using this approach.

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,217 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,609 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sumarigo-MSFT 45,321 Reputation points Microsoft Employee

    @Laron Walker For understanding the issue better: Can you please elaborate bit more on your query with the screenshot of the error message?

    When using the az webapp config storage-account command to mount a share to your Python function app, the default behavior is to mount the share as read-only. This is why you encounter the "Read-only file system" error when trying to write files to the mounted share.

    To enable write access to the mounted share, you need to explicitly specify the --mount-path option with the --access-key and --access-key-type options when executing the az webapp config storage-account command.

    Here's an example of how you can modify your command to allow write access:

    az webapp config storage-account add --name <app_name> --resource-group <resource_group> --custom-id <custom_id> --storage-type AzureFiles --share-name <share_name> --access-key <access_key> --access-key-type StorageAccessKey --mount-path /mnt/<mount_name> --read-write

    In your Python code, make sure that you are writing to the correct path within the mounted share. Based on your provided code snippet, it seems like the model_similarity_path variable should be set to the mount path. For example:

    model_similarity_path = '/mnt/<mount_name>/'

    Ensure that the <mount_name> matches the mount path specified in the --mount-path option when mounting the share.

    With these modifications, you should be able to write files to the mounted share without encountering the read-only file system error.