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

Unable to run and debug function app in VS Code #2071

Open
liliankasem opened this issue Oct 21, 2021 · 16 comments
Open

Unable to run and debug function app in VS Code #2071

liliankasem opened this issue Oct 21, 2021 · 16 comments
Assignees
Labels

Comments

@liliankasem
Copy link
Member

liliankasem commented Oct 21, 2021

Function App name

N/A - local

Tools used

  • VS Code
  • Azure Functions VS Code Extension v1.5.2
  • dotnet --version = 6.0.100-rc.2.21505.57
  • func --version = 4.0.3780

New V4 app or existing V3 app migrated to V4

New v4 app - dotnet in-proc

Issue

After creating a new v4 app (.net v6 in-proc) using the functions VS Code extension, I am not able to run and debug the function app with the .vscode configuration that was added by the template. The application runs fine and as expected when using cli i.e. func start. My assumption here is that the templated .vscode config is wrong?

Expected

Pressing F5 in VS Code after a newly generated function app with VS Code config should build and run the function application in debug mode

Actual

Pressing F5 in VS Code after a newly generated function app with VS Code config builds and runs the function app, which then shuts down immediately after

Screen Shot 2021-10-21 at 2 19 09 PM

@liliankasem
Copy link
Member Author

Might be worth mentioning that this works as expected when creating a new v4 dotnet isolated app, hitting F5 builds and runs the function app without crashing

@AdamCoulterOz
Copy link

AdamCoulterOz commented Nov 25, 2021

I'm having this same issue with the GA release also ...

dotnet v6.0.100
func v4.0.3971
code v1.62.3
ms-dotnettools.csharp v1.23.16
ms-azuretools.vscode-azurefunctions v1.6.0
Microsoft.NET.Sdk.Functions v4.0.1

@anthonychu
Copy link
Member

@nturinski might be able to help here.

@AdamCoulterOz
Copy link

@nturinski please help ... hard to work without this

@nturinski
Copy link

I was able to debug with the template HTTP Trigger using .NET 6 without altering anything. My environment configuration is listed below.

From the original post, the error seems like it's having an issue creating directories in the /dev/ folder. Are you using a remote workspace or VS Code online by chance?

OS: win32
OS Release: 10.0.19042
dotnet v6.0.100-rc.1.21463.6
func v4.0.3780
code v1.62.0-insider
ms-azuretools.vscode-azurefunctions v1.6.0
Microsoft.NET.Sdk.Functions v4.0.1

image

@AdamCoulterOz
Copy link

AdamCoulterOz commented Nov 30, 2021

Do people actually still use windows to dev? haha 😛

@nturinski You've built it as an isolated, which @liliankasem said does work. I believe we are both having problems with non-isolated (integrated? with the process worker). Also, its not a problem (for me) running the function host using core tools, it's that the vscode debugger attachment crashes... the func app keeps running, but vscode has no connection to it.

image

I also should've been more clear with my environment, I'm on macOS.

OS
ProductName:    macOS
ProductVersion: 12.0.1
BuildVersion:   21A559

dotnet v6.0.100
func v4.0.3971
func runtime v4.0.1.16815
code v1.62.3
ms-dotnettools.csharp v1.23.16
ms-azuretools.vscode-azurefunctions v1.6.0
Microsoft.NET.Sdk.Functions v4.0.1

The project is created entirely from the vscode new func project command, accepting all the defaults.

debug_func.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "<connectionStringToRealAzStorageAccount>",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to .NET Functions",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:azureFunctions.pickProcess}"
        }
    ]
}

settings.json

{
    "azureFunctions.deploySubpath": "bin/Release/net6.0/publish",
    "azureFunctions.projectLanguage": "C#",
    "azureFunctions.projectRuntime": "~4",
    "debug.internalConsoleOptions": "neverOpen",
    "azureFunctions.preDeployTask": "publish (functions)"
}

tasks.json

{
	"version": "2.0.0",
	"tasks": [
		{
			"label": "clean (functions)",
			"command": "dotnet",
			"args": [
				"clean",
				"/property:GenerateFullPaths=true",
				"/consoleloggerparameters:NoSummary"
			],
			"type": "process",
			"problemMatcher": "$msCompile"
		},
		{
			"label": "build (functions)",
			"command": "dotnet",
			"args": [
				"build",
				"/property:GenerateFullPaths=true",
				"/consoleloggerparameters:NoSummary"
			],
			"type": "process",
			"dependsOn": "clean (functions)",
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"problemMatcher": "$msCompile"
		},
		{
			"label": "clean release (functions)",
			"command": "dotnet",
			"args": [
				"clean",
				"--configuration",
				"Release",
				"/property:GenerateFullPaths=true",
				"/consoleloggerparameters:NoSummary"
			],
			"type": "process",
			"problemMatcher": "$msCompile"
		},
		{
			"label": "publish (functions)",
			"command": "dotnet",
			"args": [
				"publish",
				"--configuration",
				"Release",
				"/property:GenerateFullPaths=true",
				"/consoleloggerparameters:NoSummary"
			],
			"type": "process",
			"dependsOn": "clean release (functions)",
			"problemMatcher": "$msCompile"
		},
		{
			"label": "launch",
			"type": "func",
			"dependsOn": "build (functions)",
			"options": {
				"cwd": "${workspaceFolder}/bin/Debug/net6.0"
			},
			"command": "host start",
			"isBackground": true,
			"problemMatcher": "$func-dotnet-watch"
		}
	]
}

@liliankasem
Copy link
Member Author

liliankasem commented Nov 30, 2021

I was able to debug with the template HTTP Trigger using .NET 6 without altering anything. My environment configuration is listed below.

From the original post, the error seems like it's having an issue creating directories in the /dev/ folder. Are you using a remote workspace or VS Code online by chance?

OS: win32
OS Release: 10.0.19042
dotnet v6.0.100-rc.1.21463.6
func v4.0.3780
code v1.62.0-insider
ms-azuretools.vscode-azurefunctions v1.6.0
Microsoft.NET.Sdk.Functions v4.0.1

image

Nope, running vs code local on a mac and in-proc (no issues with the isolated template)

@josmithua
Copy link

Same here. macOS, azure-functions-core-tools@4, trying to debug the .NET 6 (non isolated) template:

Screen.Recording.2021-12-13.at.11.22.04.mov

@nturinski
Copy link

nturinski commented Dec 21, 2021

Sorry for the late reply all-- I was out for the holidays. I'll start investigating this now.

@AdamCoulterOz
Copy link

Sorry for the late reply all-- I was out for the holidays. I'll start investigating this now.

any updates on this @nturinski ? ☺️

@Arash-Sabet
Copy link

This issue is happening for dotnet-isolated functions in macOS Monterey 12.2 with M1 Pro chip. This workaround never worked. Any updates on a fix or workaround @nturinski ?

@nturinski
Copy link

Hi @Arash-Sabet

For any M1 issues, the Core tools team has a roll-up issue tracking it here: Azure/azure-functions-core-tools#2834. Unfortunately, I'm not sure if there's anything we can do on the tooling side to fix this as we just core tools and attach.

If you're not using an M1, I think that the workaround cited above should work. Sorry, we haven't had the bandwidth to implement this in the extension.

I know this has been a major pain in the butt and has affected productivity. I'm really sorry about, we will try to get this resolved soon.

@AdamCoulterOz
Copy link

AdamCoulterOz commented Feb 7, 2022

@nturinski - it looks like dotnet/vscode-csharp#4903 is actually a duplicate of this issue. I'm at least not using M1.

Is this a problem with the Azure Functions runtime or the OmniSharp language server?

@johnnyreilly
Copy link

johnnyreilly commented Nov 11, 2022

I've needed to refer back to @basilfx's workaround so often that I've turned it into a blog post here: https://johnnyreilly.com/debugging-azure-functions-vs-code-mac-os (credit attributed to @basilfx)

@fernandezafb
Copy link

I having the same problem @nturinski. I'm using an intel based mac 12.6.3, not M1. Exactly same problem. The signer workaround didn't work for me. This is indeed a pain in the but as we can't debug using VS Code.

@DZwell
Copy link

DZwell commented Jun 13, 2023

I've needed to refer back to @basilfx's workaround so often that I've turned it into a blog post here: https://blog.johnnyreilly.com/2022/11/11/debugging-azure-functions-vs-code-mac-os (credit attributed to @basilfx)

Huzzah! This fixed me, at least for now. Thank you for this blog post! Needing to litter the code with Console.WriteLine to figure out what's going on is no fun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants