Skip to main content

@ensono-stacks/azure-node

Configures your NodeJS application to use various Azure services:

Setting up @ensono-stacks/azure-node

Install the @ensono-stacks/azure-node with the following command:

npm install --save-dev @ensono-stacks/azure-node@latest

Executors and Generators

To see a list of the plugin capabilities run the following command:

nx list @ensono-stacks/azure-node

View additional information about a plugin capability through the following command:

nx g @ensono-stacks/azure-node:[generator-executor-name] --help

Generators

@ensono-stacks/azure-node:app-insights

Installs and configures App Insights in your NodeJS app.

This generator will add and configure applicationinsights npm package for you.

Prerequisites

  • Requires a NodeJs server for application insights to hook into.
tip

Use the @nx/next:custom-server generator which will have been added to your workspace by @ensono-stacks/workspace` to generate your NodeJS server!

  • Requires the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable to be set.
warning

There is a known issue with the @nx/next:custom-server impacting customServerTarget when typescript libraries are present in the monorepo. Please check the following Github Issue for the status of this issue.

Usage

nx generate @ensono-stacks/azure-node:app-insights

Command line arguments

The following command line arguments are available:

OptionDescriptionType
--projectTarget project name.string
--applicationinsightsConnectionStringThe env variable that stores the app insights connection string.string
--serverPath to custom server file inside the project.string

Generator Output

  • Adds applicationinsights dependency in package.json.
  • Extends main() function in the server file to initialise and configure app insights.

@ensono-stacks/azure-node:app-insights-deployment

Configure Deployment & Infra for application insights

This generator will make sure your dockerfile is using the custom server, and your environment variable is set.

Prerequisites

  • Requires an existing application with deployment code already generated for it
  • Requires the APPLICATIONINSIGHTS_CONNECTION_STRING secret to exist

Usage

nx generate @ensono-stacks/azure-node:app-insights-deployment

Command line arguments

The following command line arguments are available:

OptionDescriptionType
--projectTarget project name.string
--applicationinsightsConnectionStringThe env variable that stores the app insights connection string.string

Generator Output

  • Updates targets in project.json.
  • Updates pipline stages to make sure env variables are passed down
  • Updates Dockerfile if necessary to make sure it uses the custom server