如何通过 Azure CLI "Import App Service Certificate"(无 PFX 上传)
How to "Import App Service Certificate" through Azure CLI (without PFX upload)
我们目前正在使用 Azure CLI 以便从第三方应用程序动态创建资源。
一切顺利,除了为我们动态创建的应用服务导入应用证书。
我们确实有 "App Service Certificate",通过门户我们可以毫无问题地导入它。
但是我们如何通过 Azure CLI 无需 download/upload .PFX
文件来做到这一点?
是否有类似下面伪命令的命令?
az app service --add-app-service-certificate -subscriptionId MY_SUB -app-service MY_APP_SERVICE --certificate MY_APP_SERVICE_CERTIFICATE
这是我正在谈论的内容的屏幕截图:
我假设您正在寻找一种无需使用 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 做到这一点而不必 download/upload .PFX 文件?”如果不在本地下载证书文件,这是不可能的。
但您可以简单地使用 Azure CLI 命令将其导入。
希望对您有所帮助。
我们目前正在使用 Azure CLI 以便从第三方应用程序动态创建资源。
一切顺利,除了为我们动态创建的应用服务导入应用证书。
我们确实有 "App Service Certificate",通过门户我们可以毫无问题地导入它。
但是我们如何通过 Azure CLI 无需 download/upload .PFX
文件来做到这一点?
是否有类似下面伪命令的命令?
az app service --add-app-service-certificate -subscriptionId MY_SUB -app-service MY_APP_SERVICE --certificate MY_APP_SERVICE_CERTIFICATE
这是我正在谈论的内容的屏幕截图:
我假设您正在寻找一种无需使用 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 做到这一点而不必 download/upload .PFX 文件?”如果不在本地下载证书文件,这是不可能的。
但您可以简单地使用 Azure CLI 命令将其导入。
希望对您有所帮助。