- 於 D:\home\site\deployments\tools\ 下新增 PostDeploymentActions 目錄
- 於目錄內增加 Post Deployment Actions Scripts,可以是 .cmd 或 .ps1 結尾的檔案,加入的檔案將會依序執行
- 於檔案內寫入要執行的語法
- kudu 提供 unzip command 來將 zip 檔解壓縮
- 如果不要讓 command 跳出詢問視窗,可以在 檔名參數前加 -o 來 override
- 要指定解壓路徑,於檔名後 -d 加路徑,不存在的路徑將會自動建立
unzip -o D:\home\site\wwwroot\publish\publish.zip -d D:\home\site\wwwroot\publish
加入 Post Deployment Action Script 的方法有幾種:
- 使用 ftp 上傳
- 使用 app service 管理工具 kudu 的 web console 來透過 command line 新增檔案
- Site:https://my-azure.azurewebsites.net
- Kudu:https://my-azure.scm.azurewebsites.net
在 kudu console 中可以順道測試 script,推薦使用
如果要在 powershell script 裡面輸出任何字串,應用 Write-Output 來取代
輸出的任何字串將會在 git depoly 執行時回應在 git push 的結果畫面上
https://github.com/projectkudu/kudu/wiki/Post-Deployment-Action-Hooks
https://superuser.com/questions/100656/linux-unzip-command-option-to-force-overwrite