Azure Web Apps ã« Git ã§ãããã¤ããå ´åã«ä½ããããããã¤ã¹ã¯ãªããã¯ãããããã¡ã¤ã«ã¨ bash ã® 2 種é¡ãé¸æã§ãã¾ãããæ£ç´ãªã¨ããæ©è½ä¸è¶³æãå¦ãã¾ããã
ã¿ã¤ãã«éãã§ãã deploy.cmd ã PowerShell ã§æ¸ãç´ãã¾ãããããã§æè»ã«å¦çãæ¸ããã¯ãã§ãã
# ---------------------- # KUDU Deployment Script # Version: 0.2.2 # ---------------------- # Helpers # ------- function exitWithMessageOnError($1) { if ($? -eq $false) { echo "An error has occurred during web site deployment." echo $1 exit 1 } } # Prerequisites # ------------- # Verify node.js installed where.exe node 2> $null > $null exitWithMessageOnError "Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment." # Setup # ----- $SCRIPT_DIR = $PSScriptRoot $ARTIFACTS = "$SCRIPT_DIR\..\artifacts" $KUDU_SYNC_CMD = $env:KUDU_SYNC_CMD $DEPLOYMENT_SOURCE = $env:DEPLOYMENT_SOURCE $DEPLOYMENT_TARGET = $env:DEPLOYMENT_TARGET $NEXT_MANIFEST_PATH = $env:NEXT_MANIFEST_PATH $PREVIOUS_MANIFEST_PATH = $env:PREVIOUS_MANIFEST_PATH if ($DEPLOYMENT_SOURCE -eq $null) { $DEPLOYMENT_SOURCE = $SCRIPT_DIR } if ($DEPLOYMENT_TARGET -eq $null) { $DEPLOYMENT_TARGET = "$ARTIFACTS\wwwroot" } if ($NEXT_MANIFEST_PATH -eq $null) { $NEXT_MANIFEST_PATH = "$ARTIFACTS\manifest" if ($PREVIOUS_MANIFEST_PATH -eq $null) { $PREVIOUS_MANIFEST_PATH = $NEXT_MANIFEST_PATH } } if ($KUDU_SYNC_CMD -eq $null) { # Install kudu sync echo "Installing Kudu Sync" npm install kudusync -g --silent exitWithMessageOnError "npm failed" # Locally just running "kuduSync" would also work $KUDU_SYNC_CMD = "$env:APPDATA\npm\kuduSync.cmd" } ################################################################################################################################## # Deployment # ---------- echo "Handling Basic Web Site deployment." # 1. KuduSync if ($env:IN_PLACE_DEPLOYMENT -ne "1") { & $KUDU_SYNC_CMD -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.ps1" exitWithMessageOnError "Kudu Sync failed" } ################################################################################################################################## # Post deployment stub if ($env:POST_DEPLOYMENT_ACTION -ne $null) { & $env:POST_DEPLOYMENT_ACTION exitWithMessageOnError "post deployment action failed" } echo "Finished successfully."
ç¸å¤ããã PowerShell åã¯ä½ãæãã§ãããã²ã¨ã¾ãåä½ãããã®ãä½ããã¨ãåºæ¥ã¾ãããåºæ¬çãªæ¹éã¨ãã¦å¦çã®æµããããããã¡ã¤ã«çã«åããã¦ããã¾ãã
.deployment ãã¡ã¤ã«ãä½æããPowerShell ã使ã£ã¦ã¹ã¯ãªãããå®è¡ããã³ãã³ãã追å ãã¦ããã¾ãã
[config] command = powershell -NoProfile -NoLogo -ExecutionPolicy Unrestricted -File deploy.ps1
ããã Web Apps ã«ãããã¤ããã¨ãããã¾ã§éãã«ãããã¤ãããã®ã確èªã§ãã¾ãã
ãã¾ã« "Window title cannot be longer than 1023 characters" ã¨ããã¨ã©ã¼ã表示ããã¦å¤±æãããã¨ãããã¾ããããã¼ã¿ã«ããåãããã¤ãè¡ãã¨åé¡ãªãåãã¾ãã
åæ§ã®ã¨ã©ã¼ã WebJob ã PowerShell ã§æ¸ããæã«ãçºçãã¦ããããã§ããä½ã¨ãªã Web Apps å´ã®åé¡ãªã®ã§ã¯ãªããã¨æã£ã¦ãã¾ãããåå ã¯ããããã£ã¦ãã¾ããã
ä¸ã«è¼ããã¹ã¯ãªããã¯ã·ã³ãã«ãª Web ãµã¤ãããããã¤ãããã®ã§ããããã¡ãã£ã¨ä¿®æ£ãã㨠ASP.NET ã¢ããªã±ã¼ã·ã§ã³ã®ãããã¤ãè¡ããããã«ãªãã¾ãã
ãã¡ãã¡ææ¸ãããã®ã¯ã¨ã¦ãããã©ãããã®ã§ããããã¤ã¹ã¯ãªããã®ã¸ã§ãã¬ã¼ã¿ã§ãã KuduScript ãå¼ã£ã¦ PowerShell çã®ã¹ã¯ãªãããçæã§ããããã«ãã¾ããã
https://github.com/shibayan/KuduScript/tree/powershell
git clone ãã¦ãã NPM ã使ã£ã¦ã¤ã³ã¹ãã¼ã«ããã¨ããã¼ã«ã«ã§ä½¿ããããã«ãªãã¾ããå ·ä½çãªã¤ã³ã¹ãã¼ã«æé ã念ã®ããã«æ¸ãã¦ããã¾ãã
npm install
npm -g install "kuduscript ã¸ã®ãã«ãã¹"
kuduscript -y -t posh -aspWAP WebApplication\WebApplication.csproj -s WebApplication.sln
ãã㧠ASP.NET ã¢ããªã±ã¼ã·ã§ã³ã®ãããã¤ç¨ã¹ã¯ãªããã PowerShell ã§çæããã¾ãã