【问题标题】:How to "Import App Service Certificate" through Azure CLI (without PFX upload)如何通过 Azure CLI “导入应用服务证书”(无需 PFX 上传)
【发布时间】:2020-02-13 23:38:40
【问题描述】:

我们目前正在使用 Azure CLI 从第三方应用程序动态创建资源。

一切顺利,除了为我们动态创建的应用服务导入应用证书。

我们确实有一个“应用服务证书”,通过门户我们可以毫无问题地导入它。

但是我们如何通过 Azure CLI无需下载/上传.PFX 文件来做到这一点?

是否有类似以下伪命令的命令?

az app service --add-app-service-certificate -subscriptionId MY_SUB -app-service MY_APP_SERVICE --certificate MY_APP_SERVICE_CERTIFICATE

这是我正在谈论的内容的屏幕截图:

【问题讨论】:

  • 假设您可以使用 Azure Key Vault,请参阅此文档。docs.microsoft.com/en-us/azure/app-service/…
  • @GeorgeChen 我已经签出了该文档,但在示例中它仍然是上传.pfx 文件。
  • 您不想上传 .Pfx 文件而不将其下载到本地计算机?是这样吗?
  • @Mason,不,我是说使用 App Service certificate 并将其存储到 Key Vault,请查看文档的前半部分。
  • @GeorgeChen 我明白了,但是我怎样才能“导入应用服务证书”而不必先从 Key Vault 下载它?

标签: azure certificate azure-web-app-service azure-cli


【解决方案1】:

我假设您正在寻找一种在不使用 Azure 门户(通过 Power shell 程序)的情况下上传证书并将其绑定到您的 azure Web 应用程序的方法。

您可以按照 George Chen 的建议简单地使用以下 CLI 命令:

thumbprint=$(az webapp config ssl upload --certificate-file $pfxPath \
--certificate-password $pfxPassword --name $webappname --resource-group $resourceGroup \
--query thumbprint --output tsv)

# Binds the uploaded SSL certificate to the web app.
az webapp config ssl bind --certificate-thumbprint $thumbprint --ssl-type SNI \
--name $webappname --resource-group $resourceGroup

您可以在下面的文档中详细了解该命令:

https://docs.microsoft.com/en-us/cli/azure/webapp/config/ssl?view=azure-cli-latest

请注意,证书文件需要存在于物理位置才能达到下面提到的命令的结果

**--certificate-file $pfxPath**

它采用文件的路径。所以回答你的问题“但是我们如何通过 Azure CLI 做到这一点而不必下载/上传 .PFX 文件?”如果不下载本地证书文件,这是不可能的。

但您可以简单地使用 Azure CLI 命令来导入它。

希望对你有帮助。

【讨论】:

猜你喜欢
  • 2023-03-17
  • 1970-01-01
  • 2021-04-24
  • 1970-01-01
  • 2018-11-07
  • 2020-01-18
  • 2022-07-16
  • 2020-01-20
  • 2019-08-05
相关资源
最近更新 更多