@nxazure/func
v1.2.1
Published
Nx plugin for Azure Functions to initialize, create, build, run and publish Azure Functions inside your NX workspace.
Downloads
7,577
Readme
Table of Contents
Quick Start
- Make sure your environment is set as described in the Azure Functions docs.
- 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. - Create an NX workspace with any method.
npx create-nx-workspace@latest my-org
- Add the @nxazure/func package
npm install -D @nxazure/func
- Initialize a function app
nx g @nxazure/func:init my-new-app
- Add a function to the app
nx g @nxazure/func:new myNewFunc --project=my-new-app --template="HTTP trigger"
- Run the function app
nx start my-new-app
Features
- Support for TS Config paths (e.g.,
import { tool } from '@my-org/my-lib'
) - Support for a single
node_modules
folder in the root dir (just like in other monorepo solutions) - Environment variables are loaded by NX (from .env files) but they can be overwritten by individual local.settings.json files
- All current templates that are supported by the
func
CLI tool are supported. - Run multiple functions at once
nx run-many --target=start --all
- Publish the function app straight to your Azure account (az login is required)
Known possible issues
- If after creation the build is failing, try updating
@types/node
and/ortypescript
versions. - To be able to publish a function to your Azure account, an az login is required first.
- If you are using the flat eslint config, you might want to add the following to the end of your base config export:
{
ignores: ['apps/**/dist', 'apps/**/_registerPaths.ts'],
}
Publish to Azure
- Sign in to Azure
az login
- Make sure you select the correct subscription
az account set --subscription "<subscription ID or name>"
You can learn more about it on Microsoft Learn.
- 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>
- Wait for the process to finish and the triggers to properly sync
Limitations
Currently, the plugin supports only TypeScript functions.