Skip to content

Latest commit

 

History

History

func

Azure Functions NX Plugin

Develop a full serverless Azure Functions solution in NX monorepo

This plugin allows you to initialize, create, build, run and publish Azure Functions inside your NX workspace.


Table of Contents

  1. Quick Start
  2. Features
  3. Known possible issues
  4. Publish to Azure
  5. Limitations

Quick Start

  1. Make sure your environment is set as described in the Azure Functions docs.
  2. Make sure you install the latest Azure Functions Core Tools. The minimum required version is 4.0.5390. You can check your currently installed version by running func --version command.
  3. Create an NX workspace with any method.
npx create-nx-workspace@latest my-org
  1. Add the @nxazure/func package
npm install -D @nxazure/func
  1. Initialize a function app
nx g @nxazure/func:init my-new-app
  1. Add a function to the app
nx g @nxazure/func:new my-new-func --project=my-new-app --template="HTTP trigger"
  1. Run the function app
nx start my-new-app

Features

  1. Support for TS Config paths (e.g., import { tool } from '@my-org/my-lib')
  2. Support for a single node_modules folder in the root dir (just like in other monorepo solutions)
  3. All current templates that are supported by the func CLI tool are supported.
  4. Run multiple functions at once nx run-many --target=start --all
  5. Publish the function app straight to your Azure account (az login is required)

Known possible issues

  1. If after creation the build is failing, try updating @types/node and/or typescript versions.
  2. To be able to publish a function to your Azure account, an az login is required first.

Publish to Azure

  1. Sign in to Azure
az login
  1. Make sure you select the correct subscription
az account set --subscription "<subscription ID or name>"

You can learn more about it on Microsoft Learn.

  1. Use the name of your local NX app and the name of your existing function app on Azure to run the publish command:
nx publish <local-app-name> -n <function-app-on-azure>
  1. Wait for the process to finish and the triggers to properly sync

Limitations

Currently, the plugin supports only TypeScript functions.