Linux容器上Azure函数的Docker问题-函数缺失导致函数运行404 [英] Docker issue with Azure Function on Linux container - function missing leading to 404 on function run

查看:90
本文介绍了Linux容器上Azure函数的Docker问题-函数缺失导致函数运行404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题是该问题的延续:

This question is a continuation of this one: Azure function HTTP triggered on linux container - function not working 404

上一个更多的是找出根本原因. MS支持人员向我指出,这可能是根本原因(但这仍有待确认;))

The previous one was more about finding out what is the root cause. And MS support guy pointed me, what could be the root cause (but this yet remains to be confirmed;) )

首先,这是我的文件夹结构(这很重要,因为网络上的大多数示例都将dockerfile放在项目文件夹中.一旦要构建引用的库,就不可能拥有它)

Firstly, here is my folder structure (this is important because most of the examples on the net assumes dockerfile in the project folder. And this is impossible to have once you have a referenced library to build)

Solution (root folder of project)
    [Project] BuildChat <-- Referenced project by MyFunctionFolder
    [Project] MyFunctionFolder
        MyFunctionFolder.csproj
        MyFunctionFolderFunc.cs <-- Inside this file there is method run with [FunctionName("MyFunctionFolderFunc")]
        [All Files] RestOfAzureFunctionFiles
    [File] MyFunctionFolderDocker

我最初的docker文件(由MS工具创建,Add-> Docker支持)为:

My initial docker file (created by MS tool, Add->Docker support) was:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/azure-functions/dotnet:3.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["BuildChat/BuildChat.csproj", "BuildChat/"]
COPY ["MyFunctionFolder/MyFunctionFolder.csproj", "MyFunctionFolder/"]
RUN dotnet restore "MyFunctionFolder/MyFunctionFolder.csproj"
COPY . .
WORKDIR "/src/MyFunctionFolder"
RUN dotnet build "MyFunctionFolder.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyFunctionFolder.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/app

在获得支持女士的答复后(我需要将其保存在/home/site/wwwroot中),最好的方法是使用:

After response from Ms support staff (that i need to have it in /home/site/wwwroot) and the best would be to use:

func init LocalFunctionsProject --worker-runtime dotnet --docker

我确实提出了我当前的docker文件:

i did came up with my current docker file:

FROM mcr.microsoft.com/azure-functions/dotnet:3.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["BuildChat/BuildChat.csproj", "BuildChat/"]
COPY ["MyFunctionFolder/MyFunctionFolder.csproj", "MyFunctionFolder/"]
RUN dotnet restore "MyFunctionFolder/MyFunctionFolder.csproj"
COPY . .
WORKDIR "/src/MyFunctionFolder"
RUN dotnet build "MyFunctionFolder.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyFunctionFolder.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/app

我从中创建的模板文件是:

The template file, from which i created that is:

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

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

我必须包括引用的项目,并更改图像以适合Azure函数3版本(此模板显然适用于版本2),我也确实添加了还原包步骤.

I have to include the referenced project and to change the images to fit Azure function 3 version (this template is clearly for version 2) I did also add the restore package step.

但是它不起作用(如前一个那样),我现在有点沮丧:DI正在寻找互联网,我看到了数十个docker文件,据称这些文件可用于其作者发布azure功能.

But it is not working (as the previous one) And I am a little bit frustrated right now :D I am looking the internet and I see dozens of docker files, which allegedly works for their authors to publish azure function.

例如在此SOF中:在接受的答案中,dockerfile是:

in accepted answer the dockerfile was:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app

COPY . ./
RUN dotnet publish myfunction -c Release -o myfunction /out

FROM mcr.microsoft.com/azure-functions/dotnet:3.0 AS base
WORKDIR /app
EXPOSE 80

COPY --from=build-env /app/ao-backendfunctions/out .

ENV AzureWebJobsScriptRoot=/app
ENV AzureFunctionsJobHost__Logging__Console__IsEnabled=true

在此示例中-显然它在/app文件夹中(不在/home/site/wwwroot中)-wtf?:D

In this example - clearly it is in /app folder (not in /home/site/wwwroot) - wtf?:D

此票证的作者发布了一个对他有用的答案-与上面的完全不同:

The author of this ticket posted an anwser, that did work for him - completely different from the above:

FROM mcr.microsoft.com/azure-functions/dotnet:2.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /src
COPY ["FunctionTestAppLinux/FunctionTestAppLinux.csproj", "FunctionTestAppLinux/"]
RUN dotnet restore "FunctionTestAppLinux/FunctionTestAppLinux.csproj"
COPY . .
WORKDIR "/src/FunctionTestAppLinux"
RUN dotnet build "FunctionTestAppLinux.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "FunctionTestAppLinux.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/app

仍然-发布到/app:)

在某些博客上: https://spin. atomicobject.com/2020/01/09/azure-functions-docker-container/ 版本是:

On some blog: https://spin.atomicobject.com/2020/01/09/azure-functions-docker-container/ the version is:

FROM microsoft/azure-functions-dotnet-core2.0:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
COPY ./bin/Release/netstandard2.0 /home/site/wwwroot

在另一个博客上( https://blog. gutek.pl/2018/03/12/azure-functions-w-docker/)的工作版本为:

On another blog (https://blog.gutek.pl/2018/03/12/azure-functions-w-docker/) working version is:

FROM microsoft/azure-functions-runtime:2.0.0-jessie
ENV AzureWebJobsScriptRoot=/home/site/wwwroot

COPY . /home/site/wwwroot

在没有任何建筑物的情况下,还原nuget软件包.

Without any building, restoring nuget packages.

说实话,我完全不高兴:)我知道,有时候有多种方法可以实现相同的功能,但是显然AzureWebJobsScriptRoot不能同时是/home/site/wwwroot/app :)而且这两个版本似乎都适用于各种人群:)

To be honest, I am totally brain fucked :) I understand, that sometimes there is more than one way to the same way, but clearly AzureWebJobsScriptRoot cannot be /home/site/wwwroot and /app at the same time :) And both version seems to be working for various people :)

以下是我容器构建中来自Azure门户的日志:

Here are the logs from Azure Portal from my container build:

2020_05_10_RD501AC582A899_docker.log:
2020-05-10 11:17:58.951 INFO  - Recycling container because of AppFrameworkVersionChange and appFrameworkVersion = myazurefunctionendpoint.azurecr.io/mobile/myazurefunctionfolder:20200510.1
2020-05-10 11:18:12.234 INFO  - Pulling image: myazurefunctionendpoint.azurecr.io/mobile/myazurefunctionfolder:20200510.1
2020-05-10 11:18:15.314 INFO  - 20200510.1 Pulling from mobile/myazurefunctionfolder
2020-05-10 11:18:15.315 INFO  - 54fec2fa59d0 Already exists
2020-05-10 11:18:15.315 INFO  - 573788d8ba26 Already exists
2020-05-10 11:18:15.315 INFO  - 65471ff99618 Already exists
2020-05-10 11:18:15.315 INFO  - bc784bb97e07 Already exists
2020-05-10 11:18:15.315 INFO  - 5b12b0dacfda Pulling fs layer
2020-05-10 11:18:15.315 INFO  - 5b12b0dacfda Downloading 4MB / 21MB
2020-05-10 11:18:15.316 INFO  - 5b12b0dacfda Downloading 11MB / 21MB
2020-05-10 11:18:15.317 INFO  - 5b12b0dacfda Downloading 14MB / 21MB
2020-05-10 11:18:18.346 INFO  - 5b12b0dacfda Downloading 19MB / 21MB
2020-05-10 11:18:18.347 INFO  - 5b12b0dacfda Verifying Checksum
2020-05-10 11:18:18.347 INFO  - 5b12b0dacfda Download complete
2020-05-10 11:18:18.363 INFO  - 5b12b0dacfda Extracting 448KB / 21MB
2020-05-10 11:18:18.384 INFO  - 5b12b0dacfda Extracting 896KB / 21MB
2020-05-10 11:18:19.878 INFO  - 5b12b0dacfda Extracting 2MB / 21MB
2020-05-10 11:18:19.972 INFO  - 5b12b0dacfda Extracting 3MB / 21MB
2020-05-10 11:18:19.972 INFO  - 5b12b0dacfda Extracting 4MB / 21MB
2020-05-10 11:18:19.973 INFO  - 5b12b0dacfda Extracting 6MB / 21MB
2020-05-10 11:18:19.973 INFO  - 5b12b0dacfda Extracting 6MB / 21MB
2020-05-10 11:18:19.973 INFO  - 5b12b0dacfda Extracting 7MB / 21MB
2020-05-10 11:18:21.199 INFO  - 5b12b0dacfda Extracting 9MB / 21MB
2020-05-10 11:18:21.549 INFO  - 5b12b0dacfda Extracting 10MB / 21MB
2020-05-10 11:18:21.761 INFO  - 5b12b0dacfda Extracting 11MB / 21MB
2020-05-10 11:18:21.966 INFO  - 5b12b0dacfda Extracting 11MB / 21MB
2020-05-10 11:18:22.227 INFO  - 5b12b0dacfda Extracting 12MB / 21MB
2020-05-10 11:18:22.472 INFO  - 5b12b0dacfda Extracting 12MB / 21MB
2020-05-10 11:18:22.763 INFO  - 5b12b0dacfda Extracting 13MB / 21MB
2020-05-10 11:18:23.183 INFO  - 5b12b0dacfda Extracting 13MB / 21MB
2020-05-10 11:18:23.362 INFO  - 5b12b0dacfda Extracting 14MB / 21MB
2020-05-10 11:18:23.755 INFO  - 5b12b0dacfda Extracting 14MB / 21MB
2020-05-10 11:18:24.831 INFO  - 5b12b0dacfda Extracting 14MB / 21MB
2020-05-10 11:18:25.302 INFO  - 5b12b0dacfda Extracting 15MB / 21MB
2020-05-10 11:18:25.605 INFO  - 5b12b0dacfda Extracting 16MB / 21MB
2020-05-10 11:18:25.857 INFO  - 5b12b0dacfda Extracting 16MB / 21MB
2020-05-10 11:18:26.230 INFO  - 5b12b0dacfda Extracting 17MB / 21MB
2020-05-10 11:18:27.029 INFO  - 5b12b0dacfda Extracting 17MB / 21MB
2020-05-10 11:18:27.276 INFO  - 5b12b0dacfda Extracting 18MB / 21MB
2020-05-10 11:18:27.394 INFO  - 5b12b0dacfda Extracting 18MB / 21MB
2020-05-10 11:18:27.843 INFO  - 5b12b0dacfda Extracting 19MB / 21MB
2020-05-10 11:18:28.127 INFO  - 5b12b0dacfda Extracting 19MB / 21MB
2020-05-10 11:18:28.801 INFO  - 5b12b0dacfda Extracting 21MB / 21MB
2020-05-10 11:18:30.263 INFO  - 5b12b0dacfda Pull complete
2020-05-10 11:18:30.360 INFO  -  Digest: sha256:b3245ab363778662212e218dfc62f6fe1bcbb868de4edebeb975692264e39360
2020-05-10 11:18:30.408 INFO  -  Status: Downloaded newer image for myazurefunctionendpoint.azurecr.io/mobile/myazurefunctionfolder:20200510.1
2020-05-10 11:18:30.436 INFO  - Pull Image successful, Time taken: 0 Minutes and 18 Seconds
2020-05-10 11:18:30.473 INFO  - Starting container for site
2020-05-10 11:18:30.473 INFO  - docker run -d -p 7266:80 --name myazurefunctionfolder_7_60c643dd -e WEBSITE_CORS_ALLOWED_ORIGINS=https://functions.azure.com,https://functions-staging.azure.com,https://functions-next.azure.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=myazurefunctionfolder -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=myazurefunctionfolder.azurewebsites.net -e WEBSITE_INSTANCE_ID=8da8a02a13a3cdde53ad6aafcd4eb717ca00dd6bc65ff07378d74a0cd859e1c0 -e HTTP_LOGGING_ENABLED=1 myazurefunctionendpoint.azurecr.io/mobile/myazurefunctionfolder:20200510.1  

2020-05-10 11:18:41.180 INFO  - Starting container for site
2020-05-10 11:18:41.180 INFO  - docker run -d -p 7751:8081 --name myazurefunctionfolder_7_60c643dd_middleware -e WEBSITE_CORS_ALLOWED_ORIGINS=https://functions.azure.com,https://functions-staging.azure.com,https://functions-next.azure.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=myazurefunctionfolder -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=myazurefunctionfolder.azurewebsites.net -e WEBSITE_INSTANCE_ID=8da8a02a13a3cdde53ad6aafcd4eb717ca00dd6bc65ff07378d74a0cd859e1c0 -e HTTP_LOGGING_ENABLED=1 appsvc/middleware:2001061754 /Host.ListenUrl=http://0.0.0.0:8081 /Host.DestinationHostUrl=http://172.16.1.6:80 /Host.UseFileLogging=true 

2020-05-10 11:18:46.446 INFO  - Initiating warmup request to container myazurefunctionfolder_7_60c643dd for site myazurefunctionfolder
2020-05-10 11:19:02.506 INFO  - Waiting for response to warmup request for container myazurefunctionfolder_7_60c643dd. Elapsed time = 16.0677747 sec
2020-05-10 11:19:18.517 INFO  - Waiting for response to warmup request for container myazurefunctionfolder_7_60c643dd. Elapsed time = 32.0791795 sec
2020-05-10 11:19:36.436 INFO  - Waiting for response to warmup request for container myazurefunctionfolder_7_60c643dd. Elapsed time = 49.9977817 sec
2020-05-10 11:20:05.041 INFO  - Container myazurefunctionfolder_7_60c643dd for site myazurefunctionfolder initialized successfully and is ready to serve requests.
2020-05-10 11:20:05.042 INFO  - Initiating warmup request to container myazurefunctionfolder_7_60c643dd_middleware for site myazurefunctionfolder
2020-05-10 11:20:11.370 INFO  - Container myazurefunctionfolder_7_60c643dd_middleware for site myazurefunctionfolder initialized successfully and is ready to serve requests.
2020-05-10 11:20:28.875 INFO  - Pulling image: myazurefunctionendpoint.azurecr.io/mobile/myazurefunctionfolder:20200510.1
2020-05-10 11:20:32.177 INFO  - 20200510.1 Pulling from mobile/myazurefunctionfolder
2020-05-10 11:20:32.178 INFO  -  Digest: sha256:b3245ab363778662212e218dfc62f6fe1bcbb868de4edebeb975692264e39360
2020-05-10 11:20:32.179 INFO  -  Status: Image is up to date for myazurefunctionendpoint.azurecr.io/mobile/myazurefunctionfolder:20200510.1
2020-05-10 11:20:32.198 INFO  - Pull Image successful, Time taken: 0 Minutes and 3 Seconds
2020-05-10 11:20:32.565 INFO  - Starting container for site
2020-05-10 11:20:32.566 INFO  - docker run -d -p 6657:80 --name myazurefunctionfolder_8_08a93355 -e WEBSITE_CORS_ALLOWED_ORIGINS=https://functions.azure.com,https://functions-staging.azure.com,https://functions-next.azure.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=myazurefunctionfolder -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=myazurefunctionfolder.azurewebsites.net -e WEBSITE_INSTANCE_ID=8da8a02a13a3cdde53ad6aafcd4eb717ca00dd6bc65ff07378d74a0cd859e1c0 -e HTTP_LOGGING_ENABLED=1 myazurefunctionendpoint.azurecr.io/mobile/myazurefunctionfolder:20200510.1  

2020-05-10 11:20:41.614 INFO  - Starting container for site
2020-05-10 11:20:41.615 INFO  - docker run -d -p 7109:8081 --name myazurefunctionfolder_8_08a93355_middleware -e WEBSITE_CORS_ALLOWED_ORIGINS=https://functions.azure.com,https://functions-staging.azure.com,https://functions-next.azure.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=myazurefunctionfolder -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=myazurefunctionfolder.azurewebsites.net -e WEBSITE_INSTANCE_ID=8da8a02a13a3cdde53ad6aafcd4eb717ca00dd6bc65ff07378d74a0cd859e1c0 -e HTTP_LOGGING_ENABLED=1 appsvc/middleware:2001061754 /Host.ListenUrl=http://0.0.0.0:8081 /Host.DestinationHostUrl=http://172.16.1.3:80 /Host.UseFileLogging=true 

2020-05-10 11:20:46.733 INFO  - Initiating warmup request to container myazurefunctionfolder_8_08a93355 for site myazurefunctionfolder
2020-05-10 11:21:02.494 INFO  - Waiting for response to warmup request for container myazurefunctionfolder_8_08a93355. Elapsed time = 15.7612638 sec
2020-05-10 11:21:16.882 INFO  - Container myazurefunctionfolder_8_08a93355 for site myazurefunctionfolder initialized successfully and is ready to serve requests.
2020-05-10 11:21:16.891 INFO  - Initiating warmup request to container myazurefunctionfolder_8_08a93355_middleware for site myazurefunctionfolder
2020-05-10 11:21:18.256 INFO  - Container myazurefunctionfolder_8_08a93355_middleware for site myazurefunctionfolder initialized successfully and is ready to serve requests.
2020_05_10_RD501AC582A899_default_docker.log:
2020-05-10T11:20:50.028672036Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Script.ChangeAnalysis.BlobChangeAnalysisStateProvider[0]
2020-05-10T11:20:50.031226105Z       Last analysis flag value '2020-05-09T23:53:16.4731910+00:00'.
2020-05-10T11:20:50.291657401Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Script.ChangeAnalysis.ChangeAnalysisService[0]
2020-05-10T11:20:50.291850999Z       Skipping breaking change analysis.

2020-05-10T11:21:12.339552452Z [40m[32minfo[39m[22m[49m: Host.Triggers.Warmup[0]
2020-05-10T11:21:12.339591252Z       Initializing Warmup Extension.
2020-05-10T11:21:13.581571261Z [40m[32minfo[39m[22m[49m: Host.Startup[503]
2020-05-10T11:21:13.581610761Z       Initializing Host. OperationId: '04df8392-1653-4549-a89a-cfe29851ceb6'.
2020-05-10T11:21:13.602683110Z [40m[32minfo[39m[22m[49m: Host.Startup[504]
2020-05-10T11:21:13.602699410Z       Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=04df8392-1653-4549-a89a-cfe29851ceb6
2020-05-10T11:21:13.776183144Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
2020-05-10T11:21:13.776221943Z       ApplicationInsightsLoggerOptions
2020-05-10T11:21:13.776228243Z       {
2020-05-10T11:21:13.776231943Z         "SamplingSettings": {
2020-05-10T11:21:13.776235843Z           "EvaluationInterval": "00:00:15",
2020-05-10T11:21:13.776239743Z           "InitialSamplingPercentage": 100.0,
2020-05-10T11:21:13.783177961Z           "MaxSamplingPercentage": 100.0,
2020-05-10T11:21:13.783190860Z           "MaxTelemetryItemsPerSecond": 20.0,
2020-05-10T11:21:13.783196060Z           "MinSamplingPercentage": 0.1,
2020-05-10T11:21:13.783199560Z           "MovingAverageRatio": 0.25,
2020-05-10T11:21:13.783203160Z           "SamplingPercentageDecreaseTimeout": "00:02:00",
2020-05-10T11:21:13.783206760Z           "SamplingPercentageIncreaseTimeout": "00:15:00"
2020-05-10T11:21:13.783210460Z         },
2020-05-10T11:21:13.783213660Z         "SamplingExcludedTypes": null,
2020-05-10T11:21:13.783217060Z         "SamplingIncludedTypes": null,
2020-05-10T11:21:13.783220260Z         "SnapshotConfiguration": null,
2020-05-10T11:21:13.783223460Z         "EnablePerformanceCountersCollection": true,
2020-05-10T11:21:13.783226860Z         "HttpAutoCollectionOptions": {
2020-05-10T11:21:13.783238260Z           "EnableHttpTriggerExtendedInfoCollection": true,
2020-05-10T11:21:13.783241660Z           "EnableW3CDistributedTracing": true,
2020-05-10T11:21:13.783244960Z           "EnableResponseHeaderInjection": true
2020-05-10T11:21:13.783248360Z         },
2020-05-10T11:21:13.783270959Z         "LiveMetricsInitializationDelay": "00:00:15",
2020-05-10T11:21:13.783274659Z         "EnableLiveMetrics": true,
2020-05-10T11:21:13.783278159Z         "EnableDependencyTracking": true
2020-05-10T11:21:13.783281959Z       }
2020-05-10T11:21:13.793179241Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
2020-05-10T11:21:13.793194241Z       LoggerFilterOptions
2020-05-10T11:21:13.793198841Z       {
2020-05-10T11:21:13.793209541Z         "MinLevel": "None",
2020-05-10T11:21:13.793213241Z         "Rules": [
2020-05-10T11:21:13.793216641Z           {
2020-05-10T11:21:13.793219741Z             "ProviderName": null,
2020-05-10T11:21:13.793222941Z             "CategoryName": null,
2020-05-10T11:21:13.793616636Z             "LogLevel": null,
2020-05-10T11:21:13.793626936Z             "Filter": "<AddFilter>b__0"
2020-05-10T11:21:13.793631436Z           },
2020-05-10T11:21:13.793634836Z           {
2020-05-10T11:21:13.793638236Z             "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
2020-05-10T11:21:13.793642036Z             "CategoryName": null,
2020-05-10T11:21:13.793645536Z             "LogLevel": "None",
2020-05-10T11:21:13.793668236Z             "Filter": null
2020-05-10T11:21:13.793671936Z           },
2020-05-10T11:21:13.793675336Z           {
2020-05-10T11:21:13.793678835Z             "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
2020-05-10T11:21:13.793682635Z             "CategoryName": null,
2020-05-10T11:21:13.793686235Z             "LogLevel": null,
2020-05-10T11:21:13.793689835Z             "Filter": "<AddFilter>b__0"
2020-05-10T11:21:13.793714535Z           },
2020-05-10T11:21:13.793717835Z           {
2020-05-10T11:21:13.793721335Z             "ProviderName": "Microsoft.Azure.WebJobs.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider",
2020-05-10T11:21:13.793742835Z             "CategoryName": null,
2020-05-10T11:21:13.793746535Z             "LogLevel": "Trace",
2020-05-10T11:21:13.793769834Z             "Filter": null
2020-05-10T11:21:13.793773834Z           }
2020-05-10T11:21:13.793777534Z         ]
2020-05-10T11:21:13.793781234Z       }
2020-05-10T11:21:13.794979520Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
2020-05-10T11:21:13.794992920Z       LoggerFilterOptions
2020-05-10T11:21:13.794997120Z       {
2020-05-10T11:21:13.795000320Z         "MinLevel": "None",
2020-05-10T11:21:13.795003820Z         "Rules": [
2020-05-10T11:21:13.795007220Z           {
2020-05-10T11:21:13.795010420Z             "ProviderName": null,
2020-05-10T11:21:13.795013820Z             "CategoryName": null,
2020-05-10T11:21:13.795385015Z             "LogLevel": null,
2020-05-10T11:21:13.795404015Z             "Filter": "<AddFilter>b__0"
2020-05-10T11:21:13.795408915Z           },
2020-05-10T11:21:13.795418615Z           {
2020-05-10T11:21:13.795422415Z             "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
2020-05-10T11:21:13.795426215Z             "CategoryName": null,
2020-05-10T11:21:13.795429615Z             "LogLevel": "None",
2020-05-10T11:21:13.795432915Z             "Filter": null
2020-05-10T11:21:13.795436415Z           },
2020-05-10T11:21:13.795439614Z           {
2020-05-10T11:21:13.795442814Z             "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
2020-05-10T11:21:13.795446414Z             "CategoryName": null,
2020-05-10T11:21:13.795449814Z             "LogLevel": null,
2020-05-10T11:21:13.795453114Z             "Filter": "<AddFilter>b__0"
2020-05-10T11:21:13.795456614Z           },
2020-05-10T11:21:13.795459814Z           {
2020-05-10T11:21:13.795463114Z             "ProviderName": "Microsoft.Azure.WebJobs.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider",
2020-05-10T11:21:13.795466614Z             "CategoryName": null,
2020-05-10T11:21:13.795469914Z             "LogLevel": "Trace",
2020-05-10T11:21:13.795473314Z             "Filter": null
2020-05-10T11:21:13.795476814Z           }
2020-05-10T11:21:13.795480014Z         ]
2020-05-10T11:21:13.795483214Z       }
2020-05-10T11:21:13.802636929Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
2020-05-10T11:21:13.802651229Z       FunctionResultAggregatorOptions
2020-05-10T11:21:13.802655629Z       {
2020-05-10T11:21:13.802659029Z         "BatchSize": 1000,
2020-05-10T11:21:13.802662528Z         "FlushTimeout": "00:00:30",
2020-05-10T11:21:13.802666128Z         "IsEnabled": true
2020-05-10T11:21:13.802669428Z       }
2020-05-10T11:21:13.805165699Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
2020-05-10T11:21:13.805181898Z       SingletonOptions
2020-05-10T11:21:13.805187198Z       {
2020-05-10T11:21:13.805191198Z         "LockPeriod": "00:00:15",
2020-05-10T11:21:13.805195398Z         "ListenerLockPeriod": "00:01:00",
2020-05-10T11:21:13.805614293Z         "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
2020-05-10T11:21:13.805624993Z         "LockAcquisitionPollingInterval": "00:00:05",
2020-05-10T11:21:13.805629393Z         "ListenerLockRecoveryPollingInterval": "00:01:00"
2020-05-10T11:21:13.805633393Z       }
2020-05-10T11:21:13.812751908Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
2020-05-10T11:21:13.812774608Z       HttpOptions
2020-05-10T11:21:13.812780508Z       {
2020-05-10T11:21:13.812784508Z         "DynamicThrottlesEnabled": false,
2020-05-10T11:21:13.812788608Z         "MaxConcurrentRequests": -1,
2020-05-10T11:21:13.812792608Z         "MaxOutstandingRequests": -1,
2020-05-10T11:21:13.813337301Z         "RoutePrefix": "api"
2020-05-10T11:21:13.813366201Z       }
2020-05-10T11:21:13.843389543Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Hosting.JobHostService[0]
2020-05-10T11:21:13.843424743Z       Starting JobHost
2020-05-10T11:21:13.884952349Z [40m[32minfo[39m[22m[49m: Host.Startup[401]
2020-05-10T11:21:13.885667840Z       Starting Host (HostId=myazurefunctionfolder, InstanceId=a8213304-1777-4fb6-bc2d-f80e6b2bee97, Version=3.0.13113, ProcessId=1, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=~3)
2020-05-10T11:21:13.912127225Z [40m[32minfo[39m[22m[49m: Host.Startup[314]
2020-05-10T11:21:13.912142725Z       Loading functions metadata
2020-05-10T11:21:14.081233911Z [40m[32minfo[39m[22m[49m: Host.Startup[315]
2020-05-10T11:21:14.081272511Z       0 functions loaded
2020-05-10T11:21:14.155195930Z [40m[32minfo[39m[22m[49m: Host.Startup[0]
2020-05-10T11:21:14.155225030Z       Generating 0 job function(s)
2020-05-10T11:21:14.258576699Z [40m[1m[33mwarn[39m[22m[49m: Host.Startup[0]
2020-05-10T11:21:14.259122493Z       No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
2020-05-10T11:21:14.286182370Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostHttpRoutesManager[0]
2020-05-10T11:21:14.286203070Z       Initializing function HTTP routes
2020-05-10T11:21:14.286208270Z       No HTTP routes mapped
2020-05-10T11:21:14.286211970Z       
2020-05-10T11:21:14.304709550Z [40m[32minfo[39m[22m[49m: Host.Startup[412]
2020-05-10T11:21:14.304724350Z       Host initialized (394ms)
2020-05-10T11:21:14.335396884Z [40m[32minfo[39m[22m[49m: Host.Startup[413]
2020-05-10T11:21:14.335417684Z       Host started (442ms)
2020-05-10T11:21:14.336352973Z [40m[32minfo[39m[22m[49m: Host.Startup[0]
2020-05-10T11:21:14.343789484Z       Job host started
2020-05-10T11:21:14.547358360Z Hosting environment: Production
2020-05-10T11:21:14.548308349Z Content root path: /
2020-05-10T11:21:14.548820443Z Now listening on: http://[::]:80
2020-05-10T11:21:14.548834343Z Application started. Press Ctrl+C to shut down.
2020-05-10T11:21:19.822115356Z [40m[32minfo[39m[22m[49m: Host.General[316]
2020-05-10T11:21:19.822147156Z       Host lock lease acquired by instance ID '8da8a02a13a3cdde53ad6aafcd4eb717'.

2020-05-10T11:22:14.362743624Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Script.ChangeAnalysis.BlobChangeAnalysisStateProvider[0]
2020-05-10T11:22:14.362788823Z       Last analysis flag value '2020-05-09T23:53:16.4731910+00:00'.
2020-05-10T11:22:14.367496867Z [40m[32minfo[39m[22m[49m: Microsoft.Azure.WebJobs.Script.ChangeAnalysis.ChangeAnalysisService[0]
2020-05-10T11:22:14.367512067Z       Skipping breaking change analysis.

2020-05-10T11:35:44.307018064Z [40m[32minfo[39m[22m[49m: Host.Controllers.Host[0]
2020-05-10T11:35:44.309602433Z       Host Status: {
2020-05-10T11:35:44.309614333Z         "id": "myazurefunctionfolder",
2020-05-10T11:35:44.309619333Z         "state": "Running",
2020-05-10T11:35:44.309623733Z         "version": "3.0.13113",
2020-05-10T11:35:44.309628533Z         "versionDetails": "3.0.13113 Commit hash: 0cf47580569246787259ef2a29624cf9e8ce61b0",
2020-05-10T11:35:44.309633133Z         "processUptime": 908010
2020-05-10T11:35:44.309637533Z       }

2020-05-10T12:05:37.146645952Z [40m[32minfo[39m[22m[49m: Host.Controllers.Host[0]
2020-05-10T12:05:37.147571141Z       Host Status: {
2020-05-10T12:05:37.147582641Z         "id": "myazurefunctionfolder",
2020-05-10T12:05:37.147587441Z         "state": "Running",
2020-05-10T12:05:37.147591640Z         "version": "3.0.13113",
2020-05-10T12:05:37.147597440Z         "versionDetails": "3.0.13113 Commit hash: 0cf47580569246787259ef2a29624cf9e8ce61b0",
2020-05-10T12:05:37.147601940Z         "processUptime": 2700861
2020-05-10T12:05:37.147606140Z       }

帮助大家! ;)

推荐答案

对于存在相同问题的任何人:最终码头工人是:

For anyone having the same issue: Final docker is:

FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["MyFunctionFolder/MyFunctionFolder.csproj", "MyFunctionFolder/"]
RUN dotnet restore "MyFunctionFolder/MyFunctionFolder.csproj"
COPY . .
WORKDIR "/src/MyFunctionFolder"
RUN dotnet build "MyFunctionFolder.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyFunctionFolder.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot

对我来说,问题(可能是根本原因)是功能应用程序的应用程序设置之一

For me also, the issue (probably the root cause) was with one of the Application Settings of the Function App

WEBSITE_RUN_FROM_PACKAGE

因此,它不起作用.一旦我删除了此应用程序设置-即可正常运行:)

Because of that, it was not working. Once I removed this app setting - it worked correctly :)

我希望它将为某人节省我找到它所需的时间.我只会补充说,我没有创建此设置(我不知道它是如何出现"的)

I hope it will save someone the time I needed to find this. I will only add, that i did not create this setting (i don't know how it "came")

我必须非常感谢Azure支持团队帮助我发现问题;)

I have to give big thanks to Azure Support Team with helping me to find the issue;)

这篇关于Linux容器上Azure函数的Docker问题-函数缺失导致函数运行404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆