1. 程式人生 > 其它 >【Azure 應用服務】App Service For Linux 環境中,如何從App Service中獲取GitHub私有庫(Private Repos)的Deploy Key(RSA key)呢?

【Azure 應用服務】App Service For Linux 環境中,如何從App Service中獲取GitHub私有庫(Private Repos)的Deploy Key(RSA key)呢?

問題描述

為App Service For Linux配置CI/CD,原始碼在GitHub私有庫中,在釋出時候報錯 Cannot find SourceControlToken with name Bitbucket. 這樣的情況如何來解決呢?在參考了文章

得知需要在GitHub/Bitbucket/GitLab中配置Deploy Key。 那麼我們如何來獲取這個Key呢?

問題解答

第一步: 在App Service門戶的Deployment Center頁面獲取使用者名稱和密碼

 

第二步: 組合獲取 SSH Key 的請求URL 

https://<$使用者名稱>:<密碼>@<站點名>.scm.chinacloudsites.cn/api/sshkey?ensurePublicKey=1
  • <$使用者名稱> : 使用第一步中的UserName代替,注意,只需要 \ 後面的部分,需要包含$符號
  • <密碼> :第一步截圖中的Password內容
  • <站點名> :當前Web App的名稱

 

第三步: 通過Postman或者curl 獲取到 ssh-rsa Key

curl https://$xxxxx:qr3kuR7ygxxxxxxxxxcDt
@xxxxxxx.scm.chinacloudsites.cn/api/sshkey?ensurePublicKey=1

 

 

附錄一: 如何在App Service for Linux中檢視 .ssh 資料夾

登入到SSH頁面:https://yourappservicename.scm.chinacloudsites.cn/webssh/host 

# find / -name .ssh

# cd /home/xxxxxxxxxxxxxxxxxxx??????????????????/.ssh

# ls -l

查詢截圖:

 

 

參考文件

1:https://erikschlegel.com/2015/06/20/azure-continuous-deployment-using-git-private-repos/ 

2:https://github.com/projectkudu/kudu/wiki/Continuous-deployment#setting-up-continuous-deployment-using-manual-steps