This is a bit old, but I will answer it anyway just in case someone comes across this question.
First, it is helpful to run grunt with colors disabled, as both the diagnostic console and the deployment logs struggle with the ANSI codes. To do this, run grunt --no-color
. This should get the STDOUT information back into the Console and into the Deploy log.
Second, I do not recommend using checked-in versions of Node or NPM. Windows Azure already has these build in to the environment, and already is configured for the special temporary paths and cache paths needed for both to execute at their best.
Project Kudu is the deployment engine powering Azure Deployments, but you already know this, since you have a .deployment file. However, the Azure Command Line Tools [npm install azure-cli --global
] will help you scaffold out some better deployment scripts that will use Azure's pre-installed Node and NPM setup.
azure site deploymentscript –-node
will get you that base node script.
From there, a few modifications are needed to deploy.sh
to get it to execute Grunt, reliably. Within deploy.sh
is a #Deployment section. Replace its contents with the following:
# Deployment
# ----------
echo Handling node.js grunt deployment.
# 1. Select node version
selectNodeVersion
# 2. Install npm packages
if [ -e "$DEPLOYMENT_SOURCE/package.json" ]; then
eval $NPM_CMD install
exitWithMessageOnError "npm failed"
fi
# 3. Install bower packages
if [ -e "$DEPLOYMENT_SOURCE/bower.json" ]; then
eval $NPM_CMD install bower
exitWithMessageOnError "installing bower failed"
./node_modules/.bin/bower install
exitWithMessageOnError "bower failed"
fi
# 4. Run grunt
if [ -e "$DEPLOYMENT_SOURCE/Gruntfile.js" ]; then
eval $NPM_CMD install grunt-cli
exitWithMessageOnError "installing grunt failed"
./node_modules/.bin/grunt --no-color clean common dist
exitWithMessageOnError "grunt failed"
fi
# 5. KuduSync to Target
"$KUDU_SYNC_CMD" -v 500 -f "$DEPLOYMENT_SOURCE/dist" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
exitWithMessageOnError "Kudu Sync to Target failed"
This will run npm install
, followed by bower install
(if bower.json exists), followed by grunt clean common dist
(if Gruntfile.js exists), and finally a KuduSync into your /wwwroot
. (Note: replace 'clean common dist' with whatever Grunt tasks you need to run.)
There are a few other issues you may run in to. I write this up in a post on my personal blog, which includes some of the issues you may run into.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…