Reputation: 1197
This question is a continuation of this one: Azure function HTTP triggered on linux container - function not working 404
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;) )
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
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
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
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"]
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.
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.
For example in this SOF: Azure function HTTP Request 404 when published to Azure through Docker and Visual Studio
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
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
Still - publishing to /app
:)
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
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
Without any building, restoring nuget packages.
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 :)
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 }
Help guys! ;)
Upvotes: 2
Views: 5110
Reputation: 2199
For anyone coming across here because container issues with Azure DevOps pipelines and / or terraform scripts. The Release pipeline task has for runtime a dropdown that has only ".NET" and "JavaScript" as options. ".NET" results in the 2.0 image (even with v3 function and already in 2021).
But the dropdown is, in fact, a combo box and you can enter plain text here. If your choice is to use docker, you can provide a format like this:
DOCKER|mcr.microsoft.com/azure-functions/dotnet:3.0
That way you override the default behavior. According to the other answers, you can create your very own image and deploy to Azure Container Registry and than pull the image from there (with the DevOps service principal has read right on ACR) and make functions based on your very own images.
The settings overrides the site_config field "linux_fx_version". If you don't use DevOps release pipelines, but instead create function apps with terraform and deploy with other tasks, this would be the setting in the script like this (this is not a complete running example, it just illustrates the setting part):
resource "azurerm_function_app" "app" {
name = local.function_app_name
location = var.resource_group_location
resource_group_name = var.resource_group_name
app_service_plan_id = var.app_service_plan_id
storage_account_name = var.storage_account_name
storage_account_access_key = var.storage_account_access_key
version = "~3"
os_type = "linux"
site_config {
always_on = true
use_32_bit_worker_process = false
scm_type = "None"
# the value in the next field will be overwritten by Release Pipeline setting "Runtime stack"
# It's here just for the purpose of documentation. Please, don't remove, it was hard to figure out.
linux_fx_version = "DOCKER|mcr.microsoft.com/azure-functions/dotnet:3.0"
websockets_enabled = false
}
app_settings = {
FUNCTIONS_WORKER_RUNTIME = "dotnet"
FUNCTION_APP_EDIT_MODE = "readonly"
AzureWebJobsStorage = var.storage_account_connection
AzureWebJobsDashboard = var.storage_account_connection
https_only = true
WEBSITE_RUN_FROM_PACKAGE = 1
WEBSITE_ENABLE_SYNC_UPDATE_SITE = true
SCM_DO_BUILD_DURING_DEPLOYMENT = "False"
WEBSITE_HTTPLOGGING_RETENTION_DAYS = 7
}
connection_string {
name = var.storage_account_name
type = "Custom"
value = var.storage_account_connection
}
identity {
type = "SystemAssigned"
}
tags = merge(var.tags)
}
I read a lot documentation about runtime stacks and found it either misleading or incomplete or outdated (especially in conjunction with .NET 5). That's why I'm trying to document it here for further reference, not exactly for answering the question.
Upvotes: 0
Reputation: 1197
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")
I have to give big thanks to Azure Support Team with helping me to find the issue;)
Upvotes: 2