Open dewanymca opened 4 years ago
Can somebody help me?
I have same issue with Node version of the docker container.
I have the following files in the /home/site/wwwroot:
host.json lendingApplication/function.json lendingApplication/lendingApplication.js
As with original post doing func start, works a charm (ie testing locally). The docker container shows the proper default webpage on localhost but the api url doesn't show response or webpage etc. I turned on logging in the container which showed the function isn't being discovered
Dockerfile:
FROM microsoft/azure-functions-node8:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
ENV AzureFunctionsJobHost__Logging__Console__IsEnabled=true
EXPOSE 80
WORKDIR /usr/src/app
ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /opt/app && cp -a /tmp/node_modules /opt/app/
WORKDIR /opt/app
ADD . /opt/app
RUN npm run build
WORKDIR /opt/app/dist
COPY . /home/site/wwwroot
RUN echo "Deployed site file are:"
RUN echo $PWD
RUN ls
Output from docker image logs
PS C:\Users\aksljdf\Documents\GitHub\asdfasdf\api\lendingApplication> docker run -p 4001:80 lendingapplication info: Host.Startup[503] Initializing Host. info: Host.Startup[504] Host initialization: ConsecutiveErrors=0, StartupCount=1 info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0] LoggerFilterOptions { "MinLevel": "None", "Rules": [ { "ProviderName": null, "CategoryName": null, "LogLevel": null, "Filter": "<AddFilter>b__0" }, { "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider", "CategoryName": null, "LogLevel": "None", "Filter": null }, { "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider", "CategoryName": null, "LogLevel": null, "Filter": "<AddFilter>b__0" } ] } info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0] FunctionResultAggregatorOptions { "BatchSize": 1000, "FlushTimeout": "00:00:30", "IsEnabled": true } info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0] SingletonOptions { "LockPeriod": "00:00:15", "ListenerLockPeriod": "00:01:00", "LockAcquisitionTimeout": "10675199.02:48:05.4775807", "LockAcquisitionPollingInterval": "00:00:05", "ListenerLockRecoveryPollingInterval": "00:01:00" } info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0] HttpOptions { "DynamicThrottlesEnabled": false, "MaxConcurrentRequests": -1, "MaxOutstandingRequests": -1, "RoutePrefix": "api" } info: Microsoft.Azure.WebJobs.Hosting.JobHostService[0] Starting JobHost info: Host.Startup[401] Starting Host (HostId=ee9904c54a56-2137340777, InstanceId=834d4cba-9b2e-45e0-a3ca-fb1b9f972122, Version=2.0.12733.0, ProcessId=1, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=) info: Host.Startup[314] Loading functions metadata info: Host.Startup[315] 0 functions loaded info: Host.Startup[0] Generating 0 job function(s) warn: Host.Startup[0] 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.). info: Host.Startup[412] Host initialized (53ms) info: Host.Startup[413] Host started (65ms) info: Host.Startup[0] Job host started Hosting environment: Production Content root path: /opt/app/dist Now listening on: http://[::]:80 Application started. Press Ctrl+C to shut down. info: Host.General[316] Host lock lease acquired by instance ID '000000000000000000000000555F7E28'.
I fixed my issue, my DockerFile ended up as:
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
ENV AzureFunctionsJobHost__Logging__Console__IsEnabled=true
EXPOSE 80
# Create app directory
#WORKDIR /usr/src/app
# use changes to package.json to force Docker not to use the cache
# when we change our application's nodejs dependencies:
ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /opt/app && cp -a /tmp/node_modules /opt/app/
# From here we load our application's code in, therefore the previous docker
# "layer" thats been cached will be used if possible
WORKDIR /opt/app
ADD . /opt/app
RUN npm run build
# Bundle app source
RUN mkdir -p /home/site/wwwroot/ && cp -a /opt/app/dist/. /home/site/wwwroot/
WORKDIR /home/site/wwwroot
RUN echo "Deployed site file are:"
RUN echo $PWD
RUN ls```
I took the following steps to debug:
1.I took my dist folder and used `func start` (Success)
2. I took my dist folder (ie bin equivilent), and wrapped that folder in a docker image (It reproduced issue)
3. I fixed that minimum container, then used that. It worked. (My issue was my folder structure was stuffed up in container due to being new with Docker).
4. Applied my fix to my full project
Its also super key to note the difference of 401 vs 404 exceptions, as functions by default are not anonymously viewable and return 401s which in Chrome can look fairly similar to 404s
Created a Service Topic Trigger function v2 using .net core and test it locally. Everything is working locally. Tried publishing the images locally on docker and run it , getting below error:
Log are attached