問題描述
在App Service的TLS/SSL settings頁面,切換到Private Key Certificates (.pfx),通過Import Key Vault Certificate方式上傳證書,提示成功,實際沒有上傳成功。通過Upload Certificate的方式上傳證書,輸入正确的密碼,提示失敗。使用Import Key Vault Certificate,導入Key Vault中的證書,也無法成功。
問題解答
在檢視App Service的記錄檔後,發現問題原因是目前的App Service執行過Move Resource Group的操作,而上傳證書的綁定到新的Resource Group所在的WebSpace,而不是App Service所在的WebSpace,因為WebSpace在最開始建立後,就無法修改。移動到其他資源組的時候也不會修改App Service的WebSpace。
英文解釋如下:
Site 'app service name' was originally created in 'old group name xxx' resource group, but later moved to 'new group name ***' resource group. If you are trying to import certificate to this site, then the certificate will be in the WebSpace of 'new group name ***' resource group. But your website will still be in 'old group name xxx' resource group and hence will not be able to use the imported certificate.
Recommendation:
Try importing certificate from another site that is still in the original 'old group name xxx' resource group. Or upload this certificate to right WebSpace using this below CLI command:
• az webapp config ssl import --name WebsiteName --resource-group WebsiteRGName --key-vault MyKeyVault --key-vault-certificate-name MyCertificateName
• az webapp config ssl upload --name WebsiteName --resource-group WebsiteRGName --certificate-file MyPfx.pfx --certificate-password Mypassword
如果不使用上面的指令,則可以使用如下的步驟來導入證書:
- 在舊的Resource Group 中建立一個App Service, 位于同樣的區域中,并且和目标App Service使用同樣的Operating System
- 在建立的App Service中上傳 Key Vault中的證書
- 在目标App Service中确認可以看到證書
- 删除建立的Web app
- 再次在目标App Service中确認可以看到證書并正常使用
[END]