Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot debug any function locally, in VS Code #436

Closed
iamalexmang opened this issue Jul 2, 2018 · 16 comments
Closed

Cannot debug any function locally, in VS Code #436

iamalexmang opened this issue Jul 2, 2018 · 16 comments
Labels
Milestone

Comments

@iamalexmang
Copy link

Repro steps:

Action: azureFunctions.pickProcess
Error type: Error
Error Message: Failed to detect running Functions host within "60" seconds. You may want to adjust the "azureFunctions.pickProcessTimeout" setting.

Version: 0.9.1
OS: win32

@ejizba
Copy link
Contributor

ejizba commented Jul 5, 2018

@AmanG2205 can you give us some more info on how you reproduced this error?
For example:

  1. Was this a new project? What triggers have you created?
  2. Do you have the azure functions runtime installed? What version?
  3. Does this always happen for you, or only occasionally?

@ejizba ejizba added the info-needed See https://aka.ms/azcodeissuereporting label Jul 5, 2018
@Jonathan34
Copy link

Jonathan34 commented Jul 5, 2018

Same here with C# runtime, in vscode on macos 10.13.5.

1- yes, brand new with a blob trigger. the blob trigger works but never attach to the main method
2- yes

➜  ~ brew install azure-functions-core-tools
==> Installing azure-functions-core-tools from azure/functions
==> Downloading https://functionscdn.azureedge.net/public/2.0.1-beta.31/Azure.Functions.Cli.osx-x64.2.0.1-beta.31.zip

3- always, can't attach

default config files created using the azure extension. restarted vs code couple of times

@ejizba
Copy link
Contributor

ejizba commented Jul 6, 2018

This is likely due to the same issue reported in version 2.0.1-beta.30 and 2.0.1-beta.31 of the functions cli here: Azure/azure-functions-core-tools#557

You can downgrade to version 2.0.1-beta.29 as a workaround, otherwise check out that issue for workarounds on the current version

@ejizba
Copy link
Contributor

ejizba commented Jul 6, 2018

Actually I'm struggling to repro the problem on a Mac with v2.0.1-beta.31. @Jonathan34 can you copy the logs from when you F5? The stuff in the 'Terminal' window?

@Jonathan34
Copy link

> Executing task: func host start <


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

Skipping 'AzureWebJobsDashboard' from local settings as it's already defined in current environment variables.
Hosting environment: Production
Content root path: /Users/*edited*/bin/Debug/netstandard2.0
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[7/6/18 9:15:44 PM] Reading host configuration file '/Users/*edited*/bin/Debug/netstandard2.0/host.json'
[7/6/18 9:15:44 PM] Host configuration file read:
[7/6/18 9:15:44 PM] {}
[7/6/18 9:15:44 PM] Starting Host (HostId=*edited*-1707488282, InstanceId=b1f71be7-7bfa-431d-b25a-7f67b6c3883a, Version=2.0.11888.0, ProcessId=33843, AppDomainId=1, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
[7/6/18 9:15:45 PM] 'FUNCTIONS_WORKER_RUNTIME' is specified, only 'dotnet' will be enabled
[7/6/18 9:15:45 PM] Generating 1 job function(s)
[7/6/18 9:15:49 PM] Found the following functions:
[7/6/18 9:15:49 PM] *edited*.Run
[7/6/18 9:15:49 PM]
[7/6/18 9:15:49 PM] Host initialized (4242ms)
Listening on http://0.0.0.0:7071/
Hit CTRL-C to exit...
[7/6/18 9:15:49 PM] Host lock lease acquired by instance ID '000000000000000000000000E2CF709B'.
[7/6/18 9:15:49 PM] Host started (5035ms)
[7/6/18 9:15:49 PM] Job host started
[7/6/18 9:16:23 PM] Executing *edited*

Then the program executes the function for every blob in the blob storage folder.
Hope it helps...

@iamalexmang
Copy link
Author

In fact, it's not that for why I opened up this issue in the first place.
This happens on a brand new and clean installation of VS Code and the tools.
I start by clicking the Folder icon in the Azure FUnctions extension in order to create a new project. I select the beta runtime. Next, I add a new C#, HTTPTrigger function. When I click F5, I get:

> Executing task: dotnet clean <

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Finally, after 60 seconds, I get a notification saying:

Failed to detect running Functions host within "60" seconds. You may want to adjust the "azureFunctions.pickProcessTimeout" setting.

Additionally, I also get the unresolved dependencies notification. If I restore the unresolved dependencies, I get a warning saying that

Some projects have trouble loading. PLease review the output for more details.

The output says

Starting OmniSharp server at 7/7/2018, 9:00:19 AM
    Target: c:\Users\amang\Desktop\test

OmniSharp server started
    Path: C:\Users\amang\.vscode\extensions\ms-vscode.csharp-1.15.2\.omnisharp\1.30.1\OmniSharp.exe
    PID: 12868

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Enterprise 2017 15.7.27703.2035 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\amang\.vscode\extensions\ms-vscode.csharp-1.15.2\.omnisharp\1.30.1\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Enterprise 2017 15.7.27703.2035 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\amang\Desktop\test'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\Users\amang\Desktop\test
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\Users\amang\Desktop\test'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\amang\Desktop\test\test.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\amang\Desktop\test'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Stdio.Host
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\amang\Desktop\test' on host 3248.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\amang\Desktop\test\test.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\amang\Desktop\test\test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: test
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\amang\Desktop\test\test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\amang\Desktop\test\test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\amang\Desktop\test\test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\amang\Desktop\test\test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\amang\Desktop\test\test.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
        Package 'Microsoft.AspNet.WebApi.Client 5.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
c:\Users\amang\Desktop\test\test.csproj
c:\Users\amang\Desktop\test\test.csproj(0,0): Error: Package 'Microsoft.AspNet.WebApi.Client 5.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

[info]: OmniSharp.MSBuild.ProjectManager
        Update project: test

This clearly states the problem, which is that it restores the Microsoft.AspNet.WebApi.Client 5.2.2 to .NETFramework rather than .NETStandard. Hence, the program won't work.

IMHO, the restoration process messes up the entire program and this is a brand new, template based code.

@Jonathan34
Copy link

Note: the version 29 is not available via brew.... needs to be installed manually.

@ejizba
Copy link
Contributor

ejizba commented Jul 9, 2018

@AmanG2205 the problem you noted about "Microsoft.AspNet.WebApi.Client 5.2.2" is a known issue, but shouldn't be a blocker. I can successfully debug even with that warning. Just to be sure, though, you can update the version of "Microsoft.NET.Sdk.Functions" to "1.0.14" in your csproj file and that warning should go away after you restore packages.

I'm guessing 'C:\Program' is not recognized as an internal or external command, operable program or batch file. is your main problem. If it can't even do a "dotnet clean" and "dotnet build", then it's not going to be able to debug. Can you try manually running "dotnet clean" and "dotnet build" from the command prompt in your project's folder?

@Jonathan34 My log looks exactly like yours and it's working. Can you try a clean project with just an HttpTrigger instead of a BlobTrigger? Does that work for you?

@iamalexmang
Copy link
Author

Actually, I'd guess the problem is
Package 'Microsoft.AspNet.WebApi.Client 5.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
c:\Users\amang\Desktop\test\test.csproj
c:\Users\amang\Desktop\test\test.csproj(0,0): Error: Package 'Microsoft.AspNet.WebApi.Client 5.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

@Jonathan34
Copy link

Jonathan34 commented Jul 10, 2018

@EricJizbaMSFT tried a new http trigger and blob trigger with default settings. same result. (yes i triggered the http call and got Hello, asd)

I noticed:

 Error: Package 'Microsoft.AspNet.WebApi.Client 5.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

then a popup:

Failed to detect running Functions host within "60" seconds. You may want to adjust the "azureFunctions.pickProcessTimeout" setting.

i am using vscode Version 1.26.0-insider (1.26.0-insider 2018-07-10T05:05:14.117Z)

I added <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.6" /> in the csproj, that removes the warning but still cannot debug

@ejizba
Copy link
Contributor

ejizba commented Jul 11, 2018

Okay this may be my last idea. You can follow these steps to manually attach to the functions host:

  1. Create a new C# project
  2. Add an HttpTrigger
  3. Manually edit your '.csproj' file so that "Microsoft.NET.Sdk.Functions" is version "1.0.14"
  4. Wait for a prompt to restore your nuget packages and hit 'restore'
  5. Manually edit your .vscode\launch.json file from ${command:azureFunctions.pickProcess} to ${command:pickProcess}
  6. Open up the command palette (view -> Command Palette on a mac)
  7. Select 'Tasks: Run Task'
  8. Select 'Run Functions Host'
  9. Once the terminal finishes cleaning and building, start debugging
  10. Because you changed your launch.json, you will have to manually select the process. Search for func and select that process

If that works - we probably have a bug in our extension somewhere. If that still doesn't work, that means the bug is probably in the functions cli or there's some configuration problem on your machine.

@nelsonmorais
Copy link

Hi,

I had the same issue but after following up the instructions from @EricJizbaMSFT I noticed that the step 8. was failing with a 'no such file or directory' error.

Then I remembered that I had changed the project to use netcoreapp2.1 instead of netstandard2.0 (default) and I verified that the task in the tasks.json file was executing a directory change to ${workspacefolder}/bin/debug/netstandard2.0, which does not exist in my case.

After changing the directory to the correct one, all went well and I can debug :).

At the end my tasks.json looked like this (removed the parts that are not relevant for simplicity):
{
"label": "Run Functions Host",
"identifier": "runFunctionsHost",
"type": "shell",
"dependsOn": "build",
"options": {
"cwd": "${workspaceFolder}/bin/Debug/netcoreapp2.1"
},
"command": "func host start",
"isBackground": true,
"presentation": {
"reveal": "always"
},
"problemMatcher": []
}

Hope this helps others with the similar issue.

@Jonathan34
Copy link

@EricJizbaMSFT painful but works.

@ejizba
Copy link
Contributor

ejizba commented Jul 11, 2018

@Jonathan34 when you manually pick the process, does it look like this:
screen shot 2018-07-11 at 1 55 38 pm

And if you run ps from the command line, does it have the same thing listed?

  PID TTY           TIME CMD
.
.
.
23523 ttys004    0:02.99 func host start

Our extension is trying to find the 'func' process automatically and I'm wondering if yours is different for some reason.

@Jonathan34
Copy link

Jonathan34 commented Jul 11, 2018

@EricJizbaMSFT

image
image

@ejizba
Copy link
Contributor

ejizba commented Sep 4, 2018

Hey all - sorry for the delay, but I've completely refactored this and I'm hoping to get your help testing if you have time (and if you never got this working for yourself).

Please install the following vsix leveraging the "Install from VSIX" command in VS Code's command palette:
screen shot 2018-09-04 at 10 28 44 am

VSIX:
https://azcode.blob.core.windows.net/vscode-azurefunctions/ej/proc/1627/vscode-azurefunctions-0.10.1-alpha.vsix

Otherwise just follow your normal debugging routine for C# projects and let me know if it works.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants