Skip to content

ejizba/func-nodejs-prototype

Repository files navigation

Azure Functions Node.js v4 Sample App

This repository contains a sample app for the new Node.js Programming Model. The default "main" branch uses TypeScript, but you may switch to the "main-js" branch for the same app using just JavaScript.

Version 4 is currently in public preview! 🎉✨ Try it out and let us know what you think: https://aka.ms/AzFuncNodeV4

Requirements

See here

Setup

  1. Clone this repository

  2. Add a local.settings.json file with the following contents:

    {
        "IsEncrypted": false,
        "Values": {
            "FUNCTIONS_WORKER_RUNTIME": "node",
            "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
            "AzureWebJobsStorage": "<INSERT CONNECTION STRING HERE>"
        }
    }
  3. Add a connection string to the AzureWebJobsStorage setting in your local.settings.json. You may set it to UseDevelopmentStorage=true to use the local storage emulator or you may set it to a connection string for a storage account in Azure.

  4. Run npm install

  5. Run npm start

  6. Voila ✨ you have a running function app!

Steps to enable more Azure triggers

The default configuration in this repository only enables an http and timer trigger. Follow these steps to enable more functions:

  1. Change the main field in your package.json to dist/src/functions/*.js

  2. Add the following entries to the "Values" object in your local.settings.json:

    "storage_APPSETTING": "",
    "cosmosDB_APPSETTING": "",
    "serviceBus_APPSETTING": "",
    "eventHub_APPSETTING": ""
  3. Fill in the value of the above entries with a connection string for the specific type of resource you want to try out. You can skip any resource you do not want to use

  4. Run npm start!

  5. If you trigger the helloWorldWithExtraOutputs function, it will set an output binding which triggers the other azure resource functions