Eduard G
Eduard G

Reputation: 515

Azure Function running from Docker Container has different files inside

As seen on the image below, the local docker container's contents do not match the one pushed to Azure Function App. I am exploring the azure function app with Kudu and I am using docker run to interact with the local container.

This is an issue, as I have an external library that I import with DllImport, so the code can never find the actual library file no matter where I put it.

What causes this and what is the solution?

This is the last layer of my Dockerfile:

FROM mcr.microsoft.com/azure-functions/dotnet:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer ["/home/site/wwwroot", "/home/site/wwwroot"]
COPY --from=compile_engine ["/app/tmp/src/libml_inference_engine.so", "/azure-functions-host"]
COPY --from=compile_engine ["/app/tmp/src/libml_inference_engine.so", "/bin"]
COPY --from=compile_engine ["/app/tmp/src/libml_inference_engine.so", "/home/site/wwwroot"]

enter image description here

Upvotes: 0

Views: 1747

Answers (1)

Charles Xu
Charles Xu

Reputation: 31454

When you create the function app from a custom docker image, the path /home/site/wwwroot inside the container is not the same as the path /home/site/wwwroot in the kudu. There are two different containers between kudu and the container from your custom image. So you cannot see the same things on both the same paths.

The solution is that you can set the environment variable WEBSITES_ENABLE_APP_SERVICE_STORAGE as true. Then the function will use the path /home/site/wwwroot cover the same path inside the custom container. So you will see the same things in both where. It also shows all the things of that path in the portal:

enter image description here

Upvotes: 1

Related Questions