3

I'm experimenting with Azure Functions. I'm trying to use a third-party Node module in my function. However, I've been unable to figure out how to import it.

{
  "id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  "requestId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  "statusCode": 500,
  "errorCode": 0,
  "messsage": "Exception while executing function: Functions.analyze -> Error: Cannot find module 'moment'\n    at Function.Module._resolveFilename .."
}

I'm just trying to import the moment.js Node library. I was unable to find any documentation around this scenario though.

Does anyone know how to import a third-party module into Azure Functions?

1

3 Answers 3

6
  1. In your function app in the Azure portal, click Platform features and Advanced tools (Kudu).

enter image description here

  1. cd into your function directory via Debug console (CMD or PowerShell) and run the command: npm install moment.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

This is now out of date. Instead, go to Advanced Tools (Kudo) -> Bash -> cd site/wwwroot -> npm i package

Comments

0

You also can setup it with VsCode:

  1. Azure Functions: Create Function...

  2. Select JavaScript

  3. Select HTTP trigger

  4. Now you can install dependencies with you local NodeJS: enter image description here

5.You can deploy your function with the extension interface:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.