Azure / azure-functions-docker

This repo contains the base Docker images for working with azure functions
MIT License
268 stars 118 forks source link

No job functions found, Python v2 #1124

Closed rokcarl closed 2 months ago

rokcarl commented 3 months ago

I have an Azure Functions app that I'm already running in production and locally. I wanted to containerize so we can later use it in AKS or similar. So I ran func init --docker-only to get this Dockerfile. First I had the Function not implemented problem, solved it thanks to this suggestion. So I built the container docker build --platform linux/amd64 -t app . and then ran it with docker run -p 8080:80 -it app.

I got this warning, now there are no functions to call:

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.).
Here's the entire log ``` info: Host.Triggers.Warmup[0] Initializing Warmup Extension. info: Host.Startup[503] Initializing Host. OperationId: 'dc03b8bd-18fa-467a-b864-0ece4b0286de'. info: Host.Startup[504] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=dc03b8bd-18fa-467a-b864-0ece4b0286de info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0] LoggerFilterOptions { "MinLevel": "None", "Rules": [ { "ProviderName": null, "CategoryName": null, "LogLevel": null, "Filter": "b__0" }, { "ProviderName": null, "CategoryName": "Host.Function.ToolingConsoleLog", "LogLevel": "Information", "Filter": null }, { "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": "b__0" } ] } info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0] LanguageWorkerOptions { "WorkerConfigs": [ { "Description": { "Language": "python", "DefaultRuntimeName": null, "DefaultRuntimeVersion": "3.10", "SupportedArchitectures": [ "X64", "X86", "Arm64" ], "SupportedOperatingSystems": [ "LINUX", "OSX", "WINDOWS" ], "SupportedRuntimeVersions": [ "3.7", "3.8", "3.9", "3.10", "3.11" ], "SanitizeRuntimeVersionRegex": null, "WorkerIndexing": "true", "Extensions": [ ".py" ], "UseStdErrorStreamForErrorsOnly": false, "DefaultExecutablePath": "python", "DefaultWorkerPath": "/azure-functions-host/workers/python/3.10/LINUX/X64/worker.py", "WorkerDirectory": "/azure-functions-host/workers/python", "Arguments": [], "WorkerArguments": null }, "Arguments": { "ExecutablePath": "python", "ExecutableArguments": [], "WorkerPath": "/azure-functions-host/workers/python/3.10/LINUX/X64/worker.py", "WorkerArguments": [] }, "CountOptions": { "SetProcessCountToNumberOfCpuCores": false, "ProcessCount": 1, "MaxProcessCount": 10, "ProcessStartupInterval": "00:00:10", "ProcessStartupTimeout": "00:01:00", "InitializationTimeout": "00:00:10", "EnvironmentReloadTimeout": "00:00:30", "ProcessRestartInterval": "00:00:10", "ProcessShutdownTimeout": "00:00:10" } } ] } info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0] ConcurrencyOptions { "DynamicConcurrencyEnabled": false, "MaximumFunctionConcurrency": 500, "CPUThreshold": 0.8, "SnapshotPersistenceEnabled": true } 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] ScaleOptions { "ScaleMetricsMaxAge": "00:02:00", "ScaleMetricsSampleInterval": "00:00:10", "MetricsPurgeEnabled": true, "IsTargetScalingEnabled": true, "IsRuntimeScalingEnabled": false } info: Microsoft.Azure.WebJobs.Hosting.JobHostService[0] Starting JobHost info: Host.Startup[401] Starting Host (HostId=ecd00256e272-2137340777, InstanceId=4b018cee-7ed4-4bd0-81ae-af1a2933add9, Version=4.34.2.2, ProcessId=9, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null)) info: Host.Startup[314] Loading functions metadata info: Host.Startup[326] Reading functions metadata (Custom) info: Host.Startup[327] 1 functions found (Custom) 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: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0] HttpOptions { "DynamicThrottlesEnabled": false, "EnableChunkedRequestBinding": false, "MaxConcurrentRequests": -1, "MaxOutstandingRequests": -1, "RoutePrefix": "api" } info: Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostHttpRoutesManager[0] Initializing function HTTP routes No HTTP routes mapped info: Host.Startup[412] Host initialized (103ms) info: Host.Startup[413] Host started (119ms) info: Host.Startup[0] Job host started Hosting environment: Production Content root path: /azure-functions-host Now listening on: http://[::]:80 Application started. Press Ctrl+C to shut down. info: Host.General[337] Host lock lease acquired by instance ID '000000000000000000000000719A6BAC'. ^CApplication is shutting down... info: Host.Function.Console[0] Traceback (most recent call last): info: Host.Function.Console[0] File "/azure-functions-host/workers/python/3.10/LINUX/X64/worker.py", line 71, in info: Host.Function.Console[0] main.main() info: Host.Function.Console[0] File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/main.py", line 60, in main info: Host.Function.Console[0] return asyncio.run(start_async( info: Host.Function.Console[0] File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run info: Host.Function.Console[0] return loop.run_until_complete(main) info: Host.Function.Console[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete info: Host.Function.Console[0] self.run_forever() info: Host.Function.Console[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 603, in run_forever info: Host.Function.Console[0] self._run_once() info: Host.Function.Console[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1871, in _run_once info: Host.Function.Console[0] event_list = self._selector.select(timeout) info: Host.Function.Console[0] File "/usr/local/lib/python3.10/selectors.py", line 469, in select info: Host.Function.Console[0] fd_event_list = self._selector.poll(timeout, max_ev) info: Host.Function.Console[0] KeyboardInterrupt info: Microsoft.Azure.WebJobs.Hosting.JobHostService[0] Stopping JobHost info: Host.Startup[0] Job host stopped ```

Similar to #642 and #128, but not quite the same.

sudharsan2020 commented 2 months ago

Can you try this way? https://github.com/Azure/azure-functions-docker/issues/987#issuecomment-1846724440

rokcarl commented 2 months ago

I've since moved on to Azure Container Apps because of a multitude of problems with Azure Functions, so while it wasn't resolved for me, I'm closing this one.