Azure Web App usage of WEBAPP_STORAGE_HOME variable in docker-compose

Viewed 1434

I'm trying to set up a web app that has persistent storage via file share to a storage account.

I'm following various guides from Microsoft docs and I managed to do most of it, my app has persisted storage. But now, what I wanna do, I want to map volumes to my storage account.

I saw that there is this variable ${WEBAPP_STORAGE_HOME} that I can use in my docker-compose.

My question is, what is the value of this variable? The docs state:

${WEBAPP_STORAGE_HOME} is an environment variable in App Service that is mapped to persistent storage for your app.

I find this a little vague. Does it know automatically to map my path mappings? What if I have multiple path mappings? Should I set the value in the App Settings in the Configuration blade? If so, what do I need to specify, the mount path?

Besides that, I saw that it is used as following:

version: '3.3'

services:
   wordpress:
     image: mcr.microsoft.com/azuredocs/multicontainerwordpress
     volumes:
      - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/var/www/html
     ports:
       - "8000:80"
     restart: always

I'm used with named volumes in docker-compose. I figure there is no need to specify something like that?

UPDATE After @Jason Pan's answer, I tried to play with the mount a little bit.

I succeeded in having persisted storage on the App Service with the following docker-compose:

# ... lines skipped for brevity
    volumes:
      - mysql-data:/var/lib/mysql

volumes:
  mysql-data:
    driver: local

But I want to persist the data on a Storage Account. I saw that this is possible via: AppService/Configuration/Path Mappings.

My Docker Compose

# ...
    volumes:
      - MyMountedPath:/var/lib/mysql

In this docker-compose file, I have my app and a MySQL image: mysql:8 to be exact.

I mounted a path as follows: Name: MyMountedPath; Mounted Path: /usr/local/mysql; Type: Azure Files ....

And I get the following error in the logs:

2021-04-08T11:02:06.790578922Z chown: changing ownership of '/var/lib/mysql/': Operation not permitted

2021-04-08T11:02:12.785079208Z 2021-04-08 11:02:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.

Since it worked with the first approach, I suspect that there are some issues with the way my Path mapping is defined. This led me to even more questions:

  • Does my Mount Path need to exist on the App Service File system? If no, can I define something like: /foo/bar ?
  • If I have a Mount Path name MyMountedPath, can I specify in the docker-compose file something like
volumes:
  - MyMountedPath/foo:/something

Basically, navigating in the mounted path?

  • Do I need to mount this path in the File Storage in my Storage Account? Or will the App Service create this path when it will need to store something?
1 Answers

Example: In the App Service properties, I mounted an Azure File Share and gave the name

MyExternalStorage

In the docker compose configuration I have to set
volumes:
- MyExternalStorage:/var/www/html/contao

Thanks for TeddyDubois29's answer, hope it also can help you.

Web App Docker Compose Persistent Storage

Related