Azure / Azure/azure-functions-core-tools
Environment variable "AzureWebJobsScriptRoot" in Dockerfile created by azure-functions-core-tools seems invalid in Azure Functions.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 498
- Avg merge
- 5d 4h
- Merged PRs (30d)
- 15
Description
Hello Team,
I am testing to deploy custom docker image (C# Linux) to Azure Functions and found that path configured in "AzureWebJobsScriptRoot" is not valid in Azure Functions.
Why is this variable configured in the default dockerfile created by this tool even if it's invalid? Should this be removed?
Kindly confirm and thank you very much in advance!
Detail :
1, I have created C# Azure function image by following steps.
https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=bash%2Cportal&pivots=programming-language-csharp
2, In the above procedure, when we use command func init, dockerfile is created with default configuration.
Here we can see the environment variable "AzureWebJobsScriptRoot".
-----------------------
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS installer-env
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot
* To enable ssh & remote debugging on app service change the base image to the one below
FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
* FROM mcr.microsoft.com/azure-functions/dotnet:3.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
-----------------------
3, But if we test with different path for publish, no functions are shown in the Portal.
-----------------------
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS installer-env
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /test && \
dotnet publish *.csproj --output /test
* To enable ssh & remote debugging on app service change the base image to the one below
FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
* FROM mcr.microsoft.com/azure-functions/dotnet:3.0
ENV AzureWebJobsScriptRoot=/test \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
WORKDIR /test
COPY --from=installer-env ["/test", "/test"]
-----------------------

4, Based on the discussion below, I could confirm AzureWebJobsScriptRoot is now not valid in Azure Functions (mentioned that application root will always be /home/site/wwwroot).
https://github.com/MicrosoftDocs/azure-docs/issues/26761#issuecomment-475908193
Contributor guide
Research direction
Start with the Dockerfile generated by `func init` for a C# Linux function and compare the documented `/home/site/wwwroot` configuration with the alternate `/test` example. Determine whether `AzureWebJobsScriptRoot` is invalid or whether the generated path and related Dockerfile settings need correction; done means the expected function discovery behavior and configuration are confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, docker
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100