How to run npm command on azure app service after

2019-02-25 19:38发布

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

5条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-25 20:15

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
查看更多
Evening l夕情丶
3楼-- · 2019-02-25 20:29

You can run commands like npm install via the Kudu REST API.

Here's a scripted example written in PowerShell.

Add a PowerShell script task after the Azure App Service Deploy task to invoke npm install (or any other command that Kudu supports). And disable the npm install task in your build pipeline.

查看更多
女痞
4楼-- · 2019-02-25 20:35

The Kudu deployment engine that App Service leverages has the ability to run custom deployment scripts. You can include your desired npm command inside of a custom deployment script that will be executed as part of the deployment on Azure's side. No REST API calls required and everything stays in your source control system.

查看更多
走好不送
5楼-- · 2019-02-25 20:36

You can use PowerShell task or npm task to execute npm commands .

One thing to note: you also need to upload the .npmrc with auth token to Azure.

查看更多
太酷不给撩
6楼-- · 2019-02-25 20:38

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

查看更多
登录 后发表回答