Azure function - Docker image for Window VM

Atulkumar Thummar 101 Reputation points
2021-09-15T11:52:05.763+00:00

Hello Team,

I have used Azure Functions on Kubernetes with KEDA and created docker image for Window VM and hosted on AKS windows node pool.

I have used window node pool VM is Standard_B2s AKSWindows-2019-17763.2114.210811

To run azure function on window have used below base image : mcr.microsoft.com/azure-functions/dotnet:3.0-nanoserver-1809

Here is the Docker file - I have created

FROM mcr.microsoft.com/azure-functions/dotnet:3.0-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:3.1-nanoserver-1809 AS build
WORKDIR /src
COPY ["FunctionApp.csproj", "FunctionApp/"]
RUN dotnet restore "FunctionApp/FunctionApp.csproj"
COPY . .
WORKDIR "/src/FunctionApp"
RUN dotnet build "FunctionApp.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "FunctionApp.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
#ENTRYPOINT ["dotnet", "FunctionApp.dll"]   

It create docker images successfully and pulled to AKS cluster but while reviewing Pods showing below message

"Content root path: C:\app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down."


IF pass - ENTRYPOINT ["dotnet", "FunctionApp.dll"]
Then pod logs shows message as

"It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download"

Can anyone has face above issue while hosting azure based function on windows based docker containerization ? Any inputs will be helpful

Thanks

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,496 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,932 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Pramod Valavala 20,606 Reputation points Microsoft Employee
    2021-09-15T16:43:07.017+00:00

    @Atulkumar Thummar I haven't worked with Windows containers a lot but looks like the default ENTRYPOINT for nanoserver images are cmd.exe (which loads PATH and other environment variables I suppose) and the functions containers just specify CMD (even the ASP.NET ones do the same).

    So, instead of ENTRYPOINT, try CMD.

    0 comments No comments

  2. Atulkumar Thummar 101 Reputation points
    2021-09-16T05:33:33.4+00:00

    C:\WINDOWS\system32>kubectl get pods
    NAME READY STATUS RESTARTS AGE
    jobprocessor-function-5d6b785c47-9vcxh 0/1 CrashLoopBackOff 1 18s

    C:\WINDOWS\system32>kubectl logs jobprocessor-function-5d6b785c47-9vcxh
    It was not possible to find any installed .NET Core SDKs
    Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
    https://aka.ms/dotnet-download

    Same issue with CMD as well

    0 comments No comments

  3. Mittab 1 Reputation point
    2021-10-11T16:12:53.683+00:00

    I am facing the same issue. @Atulkumar Thummar , were you able to solve it? @Pramod Valavala could you help us here


  4. Stephen Harper 1 Reputation point
    2021-11-29T15:18:18.457+00:00

    The Azure Function Runtime running inside the container requires that an environment variable(AzureWebJobsScriptRoot) be set to the location of the Function App root. If you look at the base image for nanoserver-1809 this environment variable defaults to "C:\approot" but in the Docker file referenced in this question the FA is published to "C:\app"

    Try adding the below lines to the end of your Docker file:

    ENV AzureWebJobsScriptRoot=C:\app \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

    Note that the environment variable for a windows container needs to use a windows style path.

    0 comments No comments