Search code examples
azurevisual-studio-2017azure-functions

How can I debug Azure function using Visual Studio?


I'm trying to debug the Azure function, but it exists with the error "Unknown argument debug".

Please find below the screenshot of the project debug configuration.

Visual Studio Screenshot

I have referred to this link.

When I run without --debug vs, the application runs perfectly fine but I'm not able to hit the breakpoint.

I have tried host start --debug vs also, but it's also not working.

It gives the following exception.

Exception


Solution

  • I have solved the issue with the help of this link. In my case, it was the cases when the Windows username contained spaces.

    Change the launchSettings.json file to something like this:

    "newProfile1": {
          "commandName": "Executable",
          "executablePath": "C:\\Program Files\\dotnet\\dotnet.exe",
          "commandLineArgs": "\"C:\\Users\\myname\\AppData\\Roaming\\npm\\node_modules\\azure-functions-core-tools\\bin\\Azure.Functions.Cli.dll\" host start",
          "workingDirectory": "$(TargetDir)"
        }