Monday, 27 January 2020

Debug Azure Function in Visual Studio Code


Prerequisite -

Visual Studio Code (VS Code) is a code editor by Microsoft. Its an open source tool available for cross platform development so that an individual can get same experience across OS like Windows, Mac OS and Linux. 

Today we will try to debug an Azure Function (Java Script) in VS Code.

Step 1:- Use below command to initialize a new Function App

func init

Select worker runtime to node and language to javascript

Step 2:- Add new function by using command,

                func  new

Select template to Http trigger and leave function name as default. Hit enter

Step 3:- Run your function app using below command,

                func start

Note – Try it by openning the URL in any browser.

Step 4:- Use below command to open your app in VS Code.

                code .

Step 5:- Follow steps shown below to configuration VS Code to enable debugging.
  1. Hit Debug and Run
  2. Find DEBUG AND RUN -> Add Configuration
  3. launch.json file should be opened in editor.
  4. Select Node.js: Attach to Process
  5. Save changes
  6. Follow step 3 to start the function app
  7. Attached process as shown below,
  8. Add break point in index.js
  9. Try the function from any browser.
  10. The debugger should hit like,

No comments:

Post a Comment