Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run npm command on azure app service after deployment success by VSTS?

Now I can deploy from VSTS to azure, but I can't run npm after deploy is successful.

Now it is work like -> run npm install for branch files => zip => copy to azure => deploy.

I want to add npm run custom-comand to end of this chain. How to do it?

enter image description here

like image 611
Mediator Avatar asked Jun 06 '17 00:06

Mediator


People also ask

How do I run NPM on an Azure app service?

Customize build automationRun npm install without any flags, which includes npm preinstall and postinstall scripts and also installs devDependencies . Run npm run build if a build script is specified in your package. json. Run npm run build:azure if a build:azure script is specified in your package.

Which command is used to deploy a package application to Windows Azure?

Deploy a ZIP package to your web app by using the az webapp deploy command.


2 Answers

The Azure App Service Deployment task in VSTS now supports a post-deployment script. Here is a screen-shot from version 3.* of the task:

Post Deployment Action settings

See Task Parameters for more details.

Windows App Services users: Watch out for an npm bug that prevents multiple npm commands from being run (inline or in a script). For example:

npm install
npm test

Will only run npm install. There are several workarounds including this:

npm install & npm test
like image 192
DanielLarsenNZ Avatar answered Sep 21 '22 15:09

DanielLarsenNZ


There is no out of box build task to achieve the feature you want. If you do want to run the npm from Azure App Service:

Manually: You can go to Kudu console of the App Service and run npm command there:enter image description here

Automatically: You need to create your own build task to run the npm command via Kudu Rest API

like image 34
Eddie Chen - MSFT Avatar answered Sep 21 '22 15:09

Eddie Chen - MSFT