我正在尝试在 M1 Macbook 上的 Docker 容器内运行基于 .Net Core 的 Azure Function,但到目前为止尚未成功。
最初,我使用 Azure Function Core Tools CLI 通过以下命令创建该函数:func init LocalFunctionsProject --worker-runtime dotnet --docker它创建了以下 Dockerfile。
FROM mcr.microsoft.com/dotnet/core/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
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
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"]
Run Code Online (Sandbox Code Playgroud)
构建 …