Reputation: 85
This is a how to question, not a problem
I would like use an npm package in my javascript Azure function. How do I get a console in the azure functions portal to run npm install? If there is a better way to reference the npm package, this will answer my question too. A documentation reference with an example of installing the npm package in an Azure function would also be appreciated.
I apologize for this basic question. I am new to both node and azure functions and have enjoyed learning what I have so far, but this simple procedure is eluding me.
Thank you for any help you can give me
Upvotes: 6
Views: 5844
Reputation: 834
Assume the function name is function677761
Step1. Open the browser and visit the Kudo console. https://function677761.scm.azurewebsites.net/DebugConsole
Step2. In the toolbar menu select DebugConsole/CMD
Step3. Run the commands:
C:\home>ls
C:\home>cd .\site\wwwroot
C:\home\site\wwwroot>npm i date-and-time
C:\home> ls
Step4. My output is
HttpTrigger1
host.json
node_modules
package-lock.json
package.json
Step5. Now inside the file package.json there is the node.js library date-and-time just installed.
"dependencies": { "date-and-time": "^2.4.2" }
Step6. I can read the file package.json from here.
These values are custom. Depend by my account.
myemail345
group001
function677761
3877920b-027777-4513-8777a-ca378888917
Section. Manually install extensions .
Section. Folder structure
Upvotes: 3
Reputation: 222522
You can use the KUDU console at https://yourfunctionappname.scm.azurewebsites.net and navigate to the wwwroot folder and install the package that you need!
Here is an article
that i wrote to showcase how you can install python packages!
However when you deploy the azure function package.json
will have all the dependencies and you dont need to install them separately.
Upvotes: 8