func init --docker-only creates a Dockerfile that uses .NET 6 docker image, but the project is .NET 8

62 Views Asked by At

The Dockerfile generated by func init --docker-only uses other .NET version.

func init --worker-runtime dotnet-isolated creates functions project with .NET 8, then func init --docker-only creates Dockerfile that use .NET 6 images:

FROM mcr.microsoft.com/dotnet/sdk:6.0 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-isolated:4-dotnet-isolated6.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated6.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

When I do func init --worker-runtime dotnet-isolated --docker the generated Dockerfile uses .NET 8 images.

My Azure Functions Tools version is 4.0.5530.

I expected that func init --docker-only creates Dockerfile using .NET 8 images.

1

There are 1 best solutions below

0
Vivek Vaibhav Shandilya On

func init --worker-runtime dotnet-isolated creates functions project with .NET 8, then func init --docker-only creates Dockerfile that use .NET 6 images.

Because func init --docker-only commands creates a in-process image by default, func init --worker-runtime dotnet-isolated creates .NET 8 image as only isolated process supports for .NET 8 .

For reference check this document.

And in in-process , .NET 6 is the only version which supports in-process model.

link for inprocess Images. link for inprocess Images.

I created a http trigger function.

My Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:6.0 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:4-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:4
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

OUTPUT: