Search code examples
azuredockerkuduazure-app-service-envrmntazure-appservice

Azure App Service shared hosting breaking container startup


I have an Azure App Service running my own docker image based on node:14-alpine.

Deploying to the service works and the website runs as expected.

I want to be able to share a few files between the containers, I had previously been using an Azure FileStorage account mapped as a docker volume, this worked however for some reason docker/pm2/node would constantly perform writes meaning a massive cost.

I wanted to use the in-built persisted storage and set the application setting WEBSITES_ENABLE_APP_SERVICE_STORAGE to true, in theory this should share the /home directory between containers and enable storage to persist reboots.

However after changing this setting and restarting, the container no longer starts successfully and gives no reason why.

The logs I get are below:

docker run -d -p 2641:3001 --name [service_name]_2_d9625e76 -e PORT=3001 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=true -e WEBSITE_SITE_NAME=[service_name] -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=[service_name].azurewebsites.net -e WEBSITE_INSTANCE_ID=962880a44b3c94xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1e1a66c48ac6b9 -e HTTP_LOGGING_ENABLED=1 [service_name].azurecr.io/[service_name]:latest

2021-04-06T17:47:14.867Z INFO  - Initiating warmup request to container [service_name]_2_d9625e76 for site [service_name]
2021-04-06T17:47:30.612Z INFO  - Waiting for response to warmup request for container [service_name]_2_d9625e76. Elapsed time = 15.7444228 sec
... lots of lines
2021-04-06T17:56:52.574Z INFO  - Waiting for response to warmup request for container [service_name]_2_d9625e76. Elapsed time = 577.707016 sec
2021-04-06T17:57:14.909Z ERROR - Container [service_name]_2_d9625e76 for site [service_name] did not start within expected time limit. Elapsed time = 600.041979 sec
2021-04-06T17:57:14.916Z ERROR - Container [service_name]_2_d9625e76 didn't respond to HTTP pings on port: 3001, failing site start. See container logs for debugging.

I can't find any more logs to check or any reason it would fail.

What is WEBSITES_ENABLE_APP_SERVICE_STORAGE breaking about my container? I have bash access to the running kudu instance but I can't even find the node website modules.

Are there any logs that would allow me to view what is failing or anything I've not considered with the WEBSITES_ENABLE_APP_SERVICE_STORAGE setting?


Solution

  • First of all, enable persistent storage by setting the environment variable WEBSITES_ENABLE_APP_SERVICE_STORAGE as true does not affect the container operation. It only means you can use persistent storage or not.

    Second, if you set the environment variable WEBSITES_ENABLE_APP_SERVICE_STORAGE as true, then you also need to configure the mount path. Up to now, as I know it only can be configured in the docker-compose file. Here is the example.

    If you only want to deploy it in Azure Portal with a single container. Then I recommend you use the storage account. In this way, you only need to configure the mapping in the settings. Here are the steps.