pyhton linux webapps - how read/write a file in home folder throughout the project with mutiple instance

Kesavamurthi D 106 Reputation points
2022-10-23T17:37:06.383+00:00

hi

i have azure web apps linux/ flask app setup

app is running fine..

i need to read/write a file in home from container when it is hosted with multiple instance-->.gunicorn --bind=0.0.0.0 --timeout 600 --workers=4 app:app

i want to know how to write/read programmatically from any instance of container and use it in currently running .py files..

pls guide

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,074 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sreeju Nair 11,511 Reputation points
    2022-10-23T18:55:30.53+00:00

    You can use /home directory to persist data and share them across multiple instances. When persistent storage is enabled, all writes to the /home directory are persisted and can be accessed by all instances of a scaled-out app.

    Refer: https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#use-persistent-shared-storage

    Hope this helps

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 16,026 Reputation points Microsoft Employee
    2022-10-27T07:01:03.39+00:00

    @Kesavamurthi D Just checking in here if you have chance to see previous response, As suggested you can use persistent shared storage You can use the /home directory in your custom container file system to persist files across restarts and share them across instances. The /home directory is provided to enable your custom container to access persistent storage.
    When persistent storage is enabled, all writes to the /home directory are persisted and can be accessed by all instances of a scaled-out app.

    Please let us know if further query or issue remains.