Azure Functions in Visual Studio Code

Visual Studio Code is more suitable for ARM development than Visual Studio. That makes it an excellent choice for Azure development when following the “Pipelines as Code” paradigm. There’s one exception to this rule and that is Azure Functions. Azure Functions involve C# code and you want to be able to edit, build and run functions on your local development machine.

This is actually easy. A full explanation can be found at the following link: 

First install the Azure Functions extension.

Then open the folder where you want to create the function. Select the Azure Icon to see what functions you have already installed. From Azure screen: Create a new function.

You will have to choose a number of settings in the Create Function wizard, like the language, the type of trigger, the function name and namespace.

A first skeleton function appears like in Visual Studio. To build CTRL+SHIFT+B (like in Visual Studio). You can also access the build function via Terminal / Run Build Task.

In the Explorer you will see the following files are created:

  • Host.json. To configure the function host locally and in Azure. Reference:
  • Local.settings.json. App settings for functions when running locally. Reference:

Except for HTTP and timer triggers, bindings are implemented in extension packages. You must install the extension packages for the triggers and bindings that need them. In this case we build a Http trigger function, so we will skip this part.

To run and debug functions locally, press F5 (without debugging Ctrl+F5). You will be prompted to install Azure Functions Core Tools. Follow the link and download/install the Core Tools package. Core Tools includes the Azure Functions runtime (so download and installation might take some time).

After hitting F5 we see an address we can use to call the function locally. Set breakpoints and call the function from Postman. You will see the output of your function app in Postman. The streaming log is shown in the output window.

Note: If you include the ARM templates and the Azure Function Code in one directory, you need to open the specific folder with the function code in Visual Studio Code. Now you can run and debug the function. Possible you will have to add or adjust three files to the .vscode folder:

You will find the address to call from Postman on the Terminal tab down in your screen.