gpt4 book ai didi

.net - 隔离的 Azure 函数 Dockerfile

转载 作者:行者123 更新时间:2023-12-02 23:58:41 28 4
gpt4 key购买 nike

我正在尝试对隔离进程 .net5.0 Azure Function 进行 dockerize。但我收到错误。我所有的项目都以 net5.0 为目标。我的 Dockerfile 如下所示:

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

我收到的错误是:

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 notfound. [/tmp/sek2ugeb.quv/WorkerExtensions.csproj]

为什么它甚至尝试使用.net3.1?

我可以做什么来修复它?

最佳答案

我必须将此运行放入我的 dockerfile 中。它安装 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

这是我们完整的 dotnet 隔离 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"]```

关于.net - 隔离的 Azure 函数 Dockerfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67989814/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com