Azure Web App Persistent Storage - Container Data Overwritten

78 views Asked by At

Attempting to enable persistent storage. However, it keeps deleting what's in my container's folder with "hostingstart.html"

Very simple test using apache httpd (following tutorial guidance here):

version: '3.3'

services:
   apache:
     image: httpd:latest
#     volumes:
#       - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/usr/local/apache2/htdocs
     ports:
       - "8000:80"
     restart: always
  • Create Resource Group: az group create --name PandaRG --location "East US"
  • Create App Service Plan: az appservice plan create --name PandaBearAppPlan --resource-group PandaRG --sku B1 --is-linux
  • Create webapp: az webapp config container set --resource-group PandaRG --name pandabear --multicontainer-config-type compose --multicontainer-config-file docker-compose-apache.yml
  • Navigate to webapp and see default apache page "It works"
  • Enable persistent storage: az webapp config appsettings set --resource-group PandaRG --name pandabear --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE
  • Uncomment volumes and WEBAPP_STORAGE_HOME lines in docker-compose file.
  • Update app with new config: az webapp config container set --resource-group PandaRG --name pandabear --multicontainer-config-type compose --multicontainer-config-file docker-compose-apache.yml
  • Navigate back to webapp and see default apache page is gone. Now I see "hostingstart.html" listed

How can I prevent my files from being overwritten when I setup persistent storage?

1

There are 1 answers

3
Suresh Chikkam On

This behavior is often observed when Azure App Service initializes and detects an empty directory, so it places the default "hostingstart.html" file there.

  • Here, I have mounted the volumes correctly in the Docker Compose file & pointed to the correct locations for path mapping.

Webapp with a container configuration:

az webapp create --resource-group <RG-name> --plan PandaBearAppPlan --name pandabearfeb04 --multicontainer-config-type compose --multicontainer-config-file docker-compose-apache.yml

enter image description here

Enable persistent storage:

az webapp config appsettings set --resource-group <RG-name> --name pandabearfeb04 --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE

enter image description here

  • After deploying the Docker Compose configuration to Azure App Service, navigate to the web app's URL in a browser. I can be able to see the default Apache landing page.

Redeploy the Docker container with the updated test.html file to Azure App Service. enter image description here

  • Once I access the test page, I verified that the content added is displayed correctly. If the content added to the test HTML file, it means that persistent storage setup is working as expected. enter image description here

No change in app settings. enter image description here