DEV Community

Alvaro Videla
Alvaro Videla

Posted on

Azure Functions with WSL2 and Visual Studio Code

When executing Visual Studio Code through WSL2 we might find some problems when running Azure Functions locally. While those problems are easy to fix, they might leave you puzzled trying to find the solutions for them. In this article we'll look into that.

Azure Functions Core Tools are not installed

Once you have an Azure Functions project on Visual Studio Code, you might want to run it locally for debugging it by pressing F5. Here's an error you might encounter:

You must have Azure Functions Core Tools installed to debug your local functions

Alt Text

So the problem here is clearly that we don't have Azure Functions Core Tools, now the question is where to install it.

Since we are running Visual Studio Code from WSL2 we need to install the Azure Functions Core Tools on the WSL2 side. Installing them on Windows 10 won't solve this issue.

Here's how to install them on Ubuntu 18.04:

wget -q
sudo dpkg -i packages-microsoft-prod.deb

For a full set of installation instructions take a look to this article Work with Azure Functions Core Tools

Could not connect to debug target

The second problem I've found was Visual Studio Code telling me it wasn't able to attach the debugger:

Alt Text

In this case my problem was that while I did have node.js installed, I didn't have the supported version which is v12. Here's how to solve that problem:

npm install -g n
n lts

n is a program that you can use to install various versions of node.js on your system. As of this writing the LTS version (12.18.3) is the one we want, so by running n lts we can get that version running on our system.

And that's it! Two very quick solutions for problems you might find when running Azure Functions locally on WSL2 on Windows 10. Until next time!

Top comments (1)

lucaoskaique profile image
Lucas Kaíque

Did you had any problems running azure functions using Ubuntu 20 ?