Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
331 stars 100 forks source link

[BUG] Failure to debug Python Functions using VSCode + WSL2 + Ubuntu 22.04 #1436

Closed qup9 closed 2 months ago

qup9 commented 4 months ago

Tools

I am using the Code created when using Workspace/New Project... Project consistently fails with: ConnectionRefusedError: [Errno 111]

Investigative information

I have tried everything I can find on the internet including #2808; Python works on this VM; I have deleted the project and started again and restarted WSl2

If I run: func host start / func start the function works with: p://localhost:7071/api/http_trigger1?name="test"

If I try to make a C# function works as expected.

I modified launch.json to include: "command": "host start --verbose", Attached is the Output:

Requirement already satisfied: azure-functions in ./.venv/lib/python3.10/site-packages (from -r requirements.txt (line 5)) (1.18.0)

Found Python version 3.10.12 (python3).

              %%%%%%
             %%%%%%
        @   %%%%%%    @
      @@   %%%%%%      @@
   @@@    %%%%%%%%%%%    @@@
 @@      %%%%%%%%%%        @@
   @@         %%%%       @@
     @@      %%%       @@
       @@    %%      @@
            %%
            %

Azure Functions Core Tools Core Tools Version: 4.0.5455 Commit hash: N/A (64-bit) Function Runtime Version: 4.27.5.21554

[2024-02-23T18:20:57.501Z] Starting metrics publisher for container : wsl. Publishing endpoint is https://:31002/api/metrics [2024-02-23T18:20:57.557Z] Initializing LinuxContainerActivityPublisher [2024-02-23T18:20:57.557Z] Starting LinuxContainerActivityPublisher MS_FUNCTION_LOGS 5,,,,,ScriptApplicationHostOptionsSetup,"","ScmRunFromPackage is empty.",4.27.5.21554,2024-02-23T18:20:57.5600849Z,,"",,,,WSL,,,, [2024-02-23T18:20:57.607Z] Building host: version spec: , startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '93a298d3-ebf7-4eac-aea6-e67cd4fb582f' [2024-02-23T18:20:57.612Z] Reading host configuration file '/workspaces/functionApp/host.json' [2024-02-23T18:20:57.613Z] Host configuration file read: [2024-02-23T18:20:57.613Z] { [2024-02-23T18:20:57.613Z] "version": "2.0", [2024-02-23T18:20:57.614Z] "logging": { [2024-02-23T18:20:57.614Z] "applicationInsights": { [2024-02-23T18:20:57.614Z] "samplingSettings": { [2024-02-23T18:20:57.614Z] "isEnabled": true, [2024-02-23T18:20:57.614Z] "excludedTypes": "Request" [2024-02-23T18:20:57.614Z] } [2024-02-23T18:20:57.614Z] } [2024-02-23T18:20:57.615Z] }, [2024-02-23T18:20:57.615Z] "extensionBundle": { [2024-02-23T18:20:57.615Z] "id": "Microsoft.Azure.Functions.ExtensionBundle", [2024-02-23T18:20:57.615Z] "version": "[4., 5.0.0)" [2024-02-23T18:20:57.615Z] } [2024-02-23T18:20:57.615Z] } [2024-02-23T18:20:57.654Z] FUNCTIONS_WORKER_RUNTIME set to python. Skipping WorkerConfig for language: powershell [2024-02-23T18:20:57.665Z] FUNCTIONS_WORKER_RUNTIME set to python. Skipping WorkerConfig for language: node [2024-02-23T18:20:57.686Z] FUNCTIONS_WORKERRUNTIME set to python. Skipping WorkerConfig for language: java [2024-02-23T18:20:57.687Z] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /FuncExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle [2024-02-23T18:20:57.687Z] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /root/site/wwwroot/.azurefunctions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle [2024-02-23T18:20:57.687Z] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /root/data/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle [2024-02-23T18:20:57.688Z] Found a matching extension bundle at /root/data/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/4.12.0 [2024-02-23T18:20:57.703Z] Loading functions metadata [2024-02-23T18:20:57.705Z] Worker indexing is enabled [2024-02-23T18:20:57.712Z] Fetching metadata for workerRuntime: python [2024-02-23T18:20:57.712Z] Reading functions metadata (Worker) [2024-02-23T18:20:58.383Z] Language Worker Process exited. Pid=2686. [2024-02-23T18:20:58.383Z] python3 exited with code 1 (0x1). ConnectionRefusedError: [Errno 111] Connection refused,ConnectionRefusedError: [Errno 111] Connection refused. [2024-02-23T18:21:02.566Z] Posting health event {"EventTime":"2024-02-23T18:21:02.5542407Z","EventType":0,"Source":"Microsoft.Azure.WebJobs.Script.WebHost.ContainerManagement.LinuxContainerActivityPublisher","Details":"SpecializationCompleted"} [2024-02-23T18:21:02.578Z] PublishSpecializationCompleteEvent failed with System.InvalidOperationException: An invalid request URI was provided. Either the request URI must be an absolute URI or BaseAddress must be set. [2024-02-23T18:21:02.579Z] at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request) [2024-02-23T18:21:02.579Z] at System.Net.Http.HttpClient.CheckRequestBeforeSend(HttpRequestMessage request) [2024-02-23T18:21:02.579Z] at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) [2024-02-23T18:21:02.579Z] at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request) [2024-02-23T18:21:02.579Z] at Microsoft.Azure.WebJobs.Script.WebHost.Management.MeshServiceClient.SendAsync(IEnumerable`1 formData) in //src/WebJobs.Script.WebHost/Management/MeshServiceClient.cs:line 154 [2024-02-23T18:21:02.579Z] at Microsoft.Azure.WebJobs.Script.WebHost.Management.MeshServiceClient.NotifyHealthEvent(ContainerHealthEventType healthEventType, Type source, String details) in //src/WebJobs.Script.WebHost/Management/MeshServiceClient.cs:line 104 [2024-02-23T18:21:02.579Z] at Microsoft.Azure.WebJobs.Script.WebHost.ContainerManagement.LinuxContainerActivityPublisher.PublishSpecializationCompleteEvent() in //src/WebJobs.Script.WebHost/ContainerManagement/LinuxContainerActivityPublisher.cs:line 122 MS_FUNCTION_METRICS ,,,hostjsonfileconfigurationsource.loadhostconfigurationsource.initializehostconfig,0,0,0,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, MS_FUNCTION_METRICS ,,,hostjsonfileconfigurationsource.loadhostconfigurationsource.loadhostconfig,0,0,0,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, MS_FUNCTION_METRICS ,,,workerconfigfactory.getconfigs.buildworkerproviderdictionary.addprovider./usr/lib/azure-functions-core-tools-4/workers/powershell,15,15,15,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, MS_FUNCTION_METRICS ,,,workerconfigfactory.getconfigs.buildworkerproviderdictionary.addprovider./usr/lib/azure-functions-core-tools-4/workers/node,0,0,0,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, MS_FUNCTION_METRICS ,,,workerconfigfactory.getconfigs.buildworkerproviderdictionary.addprovider./usr/lib/azure-functions-core-tools-4/workers/java,20,20,20,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, MS_FUNCTION_METRICS ,,,workerconfigfactory.getconfigs.buildworkerproviderdictionary.addprovider./usr/lib/azure-functions-core-tools-4/workers/python,10,10,10,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, MS_FUNCTION_METRICS ,,,hostjsonfileconfigurationsource.loadhostconfigurationsource,5,5,5,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, MS_FUNCTION_METRICS ,,,workerprocess.start,5,5,5,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, MS_FUNCTION_METRICS ,,,workerconfigfactory.getconfigs,49,49,49,1,4.27.5.21554,2024-02-23T18:21:27.4964945Z,"{'IsStopwatchHighResolution': True}",WSL,,,, [2024-02-23T18:21:57.757Z] Starting worker process failed [2024-02-23T18:21:57.757Z] Microsoft.Azure.WebJobs.Script.Grpc: The operation has timed out. [2024-02-23T18:21:57.759Z] Failed to start language worker process for runtime: (null). workerId:c8db8ef9-b555-4ed0-bf41-9ae967be7b64 [2024-02-23T18:21:57.761Z] Removing errored webhost language worker channel for runtime: python workerId:c8db8ef9-b555-4ed0-bf41-9ae967be7b64 [2024-02-23T18:21:57.761Z] Microsoft.Azure.WebJobs.Script.Grpc: The operation has timed out. [2024-02-23T18:21:57.786Z] 0 functions loaded [2024-02-23T18:21:57.789Z] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /FuncExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle [2024-02-23T18:21:57.789Z] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /root/site/wwwroot/.azurefunctions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle [2024-02-23T18:21:57.789Z] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /root/data/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle [2024-02-23T18:21:57.789Z] Found a matching extension bundle at /root/data/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/4.12.0 [2024-02-23T18:21:57.790Z] Fetching information on versions of extension bundle Microsoft.Azure.Functions.ExtensionBundle available on https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/index.json [2024-02-23T18:21:57.827Z] Skipping bundle download since it already exists at path /root/data/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/4.12.0 [2024-02-23T18:21:57.828Z] Loading extension bundle from /root/data/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/4.12.0/bin_v3/linux-x64 [2024-02-23T18:21:57.829Z] Script Startup resetting load context with base path: '/root/data/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/4.12.0/bin_v3/linux-x64'. [2024-02-23T18:21:57.837Z] Reading host configuration file '/workspaces/functionApp/host.json' [2024-02-23T18:21:57.837Z] Host configuration file read: [2024-02-23T18:21:57.837Z] { [2024-02-23T18:21:57.837Z] "version": "2.0", [2024-02-23T18:21:57.837Z] "logging": { [2024-02-23T18:21:57.837Z] "applicationInsights": { [2024-02-23T18:21:57.837Z] "samplingSettings": { [2024-02-23T18:21:57.837Z] "isEnabled": true, [2024-02-23T18:21:57.837Z] "excludedTypes": "Request" [2024-02-23T18:21:57.837Z] } [2024-02-23T18:21:57.837Z] } [2024-02-23T18:21:57.837Z] }, [2024-02-23T18:21:57.837Z] "extensionBundle": { [2024-02-23T18:21:57.837Z] "id": "Microsoft.Azure.Functions.ExtensionBundle", [2024-02-23T18:21:57.837Z] "version": "[4., 5.0.0)" [2024-02-23T18:21:57.837Z] } [2024-02-23T18:21:57.837Z] } MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","Workers Directory set to: /usr/lib/azure-functions-core-tools-4/workers",4.27.5.21554,2024-02-23T18:21:57.9843144Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","Found worker config: /usr/lib/azure-functions-core-tools-4/workers/powershell/worker.config.json",4.27.5.21554,2024-02-23T18:21:57.9845090Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","EnvironmentVariable FUNCTIONS_WORKER_RUNTIME: python",4.27.5.21554,2024-02-23T18:21:57.9846553Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 4,,,,,Host.LanguageWorkerConfig,"","FUNCTIONS_WORKER_RUNTIME set to python. Skipping WorkerConfig for language: powershell",4.27.5.21554,2024-02-23T18:21:57.9855122Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, [2024-02-23T18:21:57.992Z] MS_FUNCTION_AZURE_MONITOR_EVENT 4,localhost:7071,Microsoft.Web/sites/functions/log,FunctionAppLogs,,"{'appName':'','roleInstance':'wsl','message':'FUNCTIONS_WORKER_RUNTIME set to python. Skipping WorkerConfig for language: powershell','category':'Host.LanguageWorkerConfig','hostVersion':'4.27.5.21554','hostInstanceId':'7719dbaf-0319-45f8-a0be-6dacebbe12c4','level':'Information','levelId':2,'processId':2651}",WSL,,02/23/2024 18:21:57 FUNCTIONS_WORKER_RUNTIME set to python. Skipping WorkerConfig for language: powershell MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","Found worker config: /usr/lib/azure-functions-core-tools-4/workers/python/worker.config.json",4.27.5.21554,2024-02-23T18:21:57.9927588Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","EnvironmentVariable FUNCTIONS_WORKER_RUNTIME: python",4.27.5.21554,2024-02-23T18:21:57.9930990Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","EnvironmentVariable FUNCTIONS_WORKER_RUNTIME_VERSION: 3.10",4.27.5.21554,2024-02-23T18:21:57.9931523Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","Added WorkerConfig for language: python",4.27.5.21554,2024-02-23T18:21:57.9932030Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","Found worker config: /usr/lib/azure-functions-core-tools-4/workers/node/worker.config.json",4.27.5.21554,2024-02-23T18:21:57.9932423Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 5,,,,,Host.LanguageWorkerConfig,"","EnvironmentVariable FUNCTIONS_WORKER_RUNTIME: python",4.27.5.21554,2024-02-23T18:21:57.9933990Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, MS_FUNCTION_LOGS 4,,,,,Host.LanguageWorkerConfig,"","FUNCTIONS_WORKER_RUNTIME set to python. Skipping WorkerConfig for language: node",4.27.5.21554,2024-02-23T18:21:57.9934933Z,,"",,7719dbaf-0319-45f8-a0be-6dacebbe12c4,,WSL,,,, [2024-02-23T18:21:57.993Z] FUNCTIONS_WORKER_RUNTIME set to python. Skipping WorkerConfig for language: nodeMS_FUNCTION_AZURE_MONITOR_EVENT 4,localhost:7071,Microsoft.Web/sites/functions/log,FunctionAppLogs,,"{'appName':'','roleInstance':'wsl','message':'FUNCTIONS_WORKER_RUNTIME set to python. Skipping WorkerConfig for language: node','category':'Host.LanguageWorkerConfig','hostVersion':'4.27.5.21554','hostInstanceId':'7719dbaf-0319-45f8-a0be-6dacebbe12c4','level':'Information','levelId':2,'processId':2651}",WSL,,02/23/2024 18:21:57 ...

bhagyshricompany commented 4 months ago

Hi @qup9 thanks for reporting please share the all steps for repro which you tried. Thanks

hallvictoria commented 3 months ago

Hi @qup9, is the issue only happening when trying to debug? Running the function with func host start works correctly?

Can you share all the steps for repro-ing? I'm able to debug and run using WSL without any errors. Here's the documentation references I used to set it up:

microsoft-github-policy-service[bot] commented 2 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.