Reputation: 44680
I'm trying to dockerize isolated process .net5.0 Azure Function. But I'm getting errors. All my projects target net5.0
. My Dockerfile looks like this:
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0-core-tools AS build
WORKDIR /app
COPY . ./
RUN dotnet publish My.Functions -c Release -o out -r linux-x64
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
ENV AzureFunctionsJobHost__Logging__Console__IsEnabled=true
ENV FUNCTIONS_WORKER_RUNTIME=dotnet-isolated
COPY --from=build /app/out /home/site/wwwroot
The error that I'm getting says:
It was not possible to find any compatible framework version [/tmp/sek2ugeb.quv/WorkerExtensions.csproj] /root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : The framework 'Microsoft.NETCore.App', version '3.1.0' was not found. [/tmp/sek2ugeb.quv/WorkerExtensions.csproj]
Why does it even try to use .net3.1?
What can I do to fix it?
Upvotes: 2
Views: 1799
Reputation: 41
I had to put this run in my dockerfile. It installs the 3.1 sdk.
RUN dotnet_sdk_version=3.1.409 && curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-x64.tar.gz && mkdir -p /usr/share/dotnet && tar -ozxf dotnet.tar.gz -C /usr/share/dotnet && rm dotnet.tar.gz
Here is our full dotnet isolated Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS installer-env
RUN dotnet_sdk_version=3.1.409 && curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-x64.tar.gz && mkdir -p /usr/share/dotnet && tar -ozxf dotnet.tar.gz -C /usr/share/dotnet && rm dotnet.tar.gz
COPY . /src/dotnet-function-app/
RUN mkdir -p /home/site/wwwroot
WORKDIR /src/dotnet-function-app/*FunctionName*
RUN dotnet publish --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"]```
Upvotes: 1