Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to mount volume in azure app service?

I am trying to deploy a Node SDK on azure app service through docker container. In my sdk, I have mounted a connection file & written a docker-compose for this. But when I deploy it by azure I get below error.

InnerException: Docker.DotNet.DockerApiException, Docker API responded with status code=InternalServerError, response={"message":"invalid volume specification: ':/usr/src/app/connection.json'"}

docker-compose.yml

version: '2'

services:
  node:
    container_name: node
    image: dhiraj1990/node-app:latest
    command: [ "npm", "start" ]
    ports:
      - "3000:3000"
    volumes:
      - ${WEBAPP_STORAGE_HOME}/site/wwwroot/connection.json:/usr/src/app/connection.json

connection.json is present at this path /site/wwwroot.

Dockerfile

FROM node:8

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

EXPOSE 3000

Please tell me what is the issue ?

like image 946
TechChain Avatar asked Aug 13 '19 06:08

TechChain


People also ask

How do I mount Azure file share in Azure app?

In the Azure portal, navigate to the app. From the left navigation, click Configuration > Path Mappings > New Azure Storage Mount.

How do I mount the volume of an azure container instance?

To mount multiple volumes in a container instance, you must deploy using an Azure Resource Manager template, a YAML file, or another programmatic method. To use a template or YAML file, provide the share details and define the volumes by populating the volumes array in the properties section of the file.

Can you mount a volume while building your Docker image?

When building an image, you can't mount a volume. However, you can copy data from another image! By combining this, with a multi-stage build, you can pre-compute an expensive operation once, and re-use the resulting state as a starting point for future iterations.

What is Websites_enable_app_service_storage?

If WEBSITES_ENABLE_APP_SERVICE_STORAGE setting is unspecified or set to false, the /home/ directory will not be shared across scale instances, and files written will not persist across restarts. Explicitly setting WEBSITES_ENABLE_APP_SERVICE_STORAGE to true will enable the mount.


1 Answers

Update:

The problem is that you cannot mount a file to the persistent storage, it should be a directory. So the correct volumes should set like below:

volumes:
      - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/usr/src/app

And you also need to enable the persistent storage in your Web app for the container by setting the environment variable WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE. For more details, see Add persistent storage.

The persistent storage is just used to persist your data from your container. And if you want to share your files to the container, I will suggest you mount the Azure File share to the container. But you need to pay attention to the caution here:

Linking an existing directory in a web app to a storage account will delete the directory contents.

So you need to mount the Azure File Share to a new directory without necessary files. And you can get more details about the steps in Configure Azure Files in a Container on App Service. It not only supports Windows containers but also supports Linux containers.

like image 170
Charles Xu Avatar answered Sep 20 '22 17:09

Charles Xu