There is some Azure Function that uses an Isolated Model, running as an out-of-process language worker that is separate from the Azure Functions runtime. Because Azure Functions runtime doesn't support .NET5 yet.
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
</PropertyGroup>
I'm looking for a way how to deploy .NET func as a Docker container.

func init LocalFunctionsProject --worker-runtime dotnet-isolated --docker
For .NET 3.1 I had Dockerfile
FROM mcr.microsoft.com/dotnet/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
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"]
How to containerize .NET5 func? Is it even possible? Any workarounds? I've not found a solution yet. Please suggest
OK, so there are two things going on:
To fix this, add the following lines after the first FROM statement in the Dockerfile:
# Build requires 3.1 SDK
COPY --from=mcr.microsoft.com/dotnet/core/sdk:3.1 /usr/share/dotnet /usr/share/dotnet
Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS installer-env
COPY --from=mcr.microsoft.com/dotnet/core/sdk:3.1 /usr/share/dotnet /usr/share/dotnet
COPY ./LocalFunctionsProject/ /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
The docs will be updated soon