For testing, the following environment variables must either be defined in the system or placed in an ".env" file located in the project root folder:
Environment Variable | Type | Description |
---|---|---|
LXR_HOST | string | LeanIX instance for tests |
LXR_APITOKEN | string | LeanIX API token for tests |
npx func init projects/demo_function_project --typescript cd projects/demo_function_project npx func new --name HttpExample --template "HTTP trigger" --authlevel "anonymous"
https://github.com/rhyek/typescript-monorepo-example
- Navigate to the function folder
- Run
npm run start
- Launch VS Code Debugger config "Attach to Azure Function"
- Set breakpoints in your code and debug it
Q: I cannot trigger any breakpoints set in my source code A: Check the following points: the "dist" folder of your function contains a source-map *.js.map file generated during the build process, the "local.settings.json" file contains a "Values" entry { "languageWorkers:node:arguments": "--inspect=9229" }, the .vscode directory in the repository root contains a "launch.json" file with a configuration of type "node", request "attach" configured for port 9929 ". Additional info here
Prerequisites: In a terminal or command window, run func --version to check that the Azure Functions Core Tools are version 4.x. Run az --version to check that the Azure CLI version is 2.4 or later. Run az login to sign in to Azure and verify an active subscription.
Step 1: Create a local function project
a. Run the func init command, as follows, to create a functions project in a folder named LocalFunctionProj with the specified runtime:
func init <YOUR FUNCTION PROJECT NAME> --typescript
b. Navigate into the project folder:
cd <YOUR FUNCTION PROJECT NAME>
c. Add a function to your project by using the following command, where the --name argument is the unique name of your function (HttpExample) and the --template argument specifies the function's trigger (HTTP).
func new --name HttpExample --template "HTTP trigger" --authlevel "function"
- Launch the function locally using the following command: func start