简体   繁体   English

如何使用PowerShell将SSL证书添加到azure网站?

[英]How to add an SSL certificate to an azure website using powershell?

I am working on automatic deployment + azure. 我正在进行自动部署+天蓝色。 I'm at the point where i'm adding an ssl cert to the website. 我正在向网站添加ssl证书。 Does anyone know how to use PowerShell to upload an SSL certificate to a website using the PowerShell command (Add - Get - Set based commands)? 有没有人知道如何使用PowerShell使用PowerShell命令(基于Add - Get - Set的命令)将SSL证书上传到网站? I'm able to add a certificate to a cloud service using ... 我可以使用...将证书添加到云服务

New-AzureService $Program -Location 'East US'
Add-AzureCertificate -Password Cert123! -ServiceName $Program -CertToDeploy $CertLocation

but I have no idea how to add it to an azure website. 但我不知道如何将它添加到天蓝色的网站。

Thanks 谢谢

edit: I've found a way using the following command, but i'm not wanting to install additional libraries on my production deployment machine. 编辑:我找到了使用以下命令的方法,但我不想在我的生产部署机器上安装其他库。

azure site cert add -k Cert123! $CertLocation $Program

Using the newly released Azure PowerShell v. 1.1.0, you can use the following command to upload a certificate to your website 使用新发布的Azure PowerShell v.1.1.0,您可以使用以下命令将证书上载到您的网站

New-AzureRmWebAppSSLBinding -ResourceGroupName myresourcegroup -WebAppName mytestapp -CertificateFilePath PathToPfxFile -CertificatePassword PlainTextPwd -Name www.contoso.com

More information is in the following article https://azure.microsoft.com/en-us/documentation/articles/app-service-web-app-powerhell-ssl-binding/ 更多信息请参阅以下文章https://azure.microsoft.com/en-us/documentation/articles/app-service-web-app-powerhell-ssl-binding/

As far as I know the Azure PowerShell cmdlets do not offer this capability at the moment that I could find. 据我所知,Azure PowerShell cmdlet在我找到的那一刻不提供此功能。 As you point out the Cross Platform Command Line tool does. 正如您指出跨平台命令行工具那样。 Since you don't want to add the XPlat-CLI tool to your deployment machines you can use what the XPlat-CLI tool does under the hood: a direct call against the REST api for web site management. 由于您不希望将XPlat-CLI工具添加到部署计算机,因此您可以使用XPlat-CLI工具所做的工作:直接调用REST api进行网站管理。

Note you'll need to figure out what webspace the site resides in, etc. You can use the Invoke-WebRequest to make this call so that you can verify you get that 200 response back. 请注意,您需要确定网站所在的网站空间等。您可以使用Invoke-WebRequest进行此调用,以便您可以验证是否得到了200响应。 Or you could use the Invoke-RESTMethod as well, but that would only return an XML document (the contents of the response). 或者您也可以使用Invoke-RESTMethod,但这只会返回一个XML文档(响应的内容)。 The Invoke-WebRequest provides you a little more control and access to the full response object. Invoke-WebRequest为您提供了对完整响应对象的更多控制和访问。

The Microsoft Azure Management Libraries (which the PowerShell cmdlets sit on top of) has a Web Site Management piece to it. Microsoft Azure管理库 (PowerShell cmdlet位于其上)具有网站管理部分。 One of the operations is an update to a site and that includes a WebSiteUpdateParameters object with a SSLCertificates property. 其中一个操作是对站点的更新,其中包括具有SSLCertificates属性的WebSiteUpdateParameters对象。 You may check into that as well, though I've not done this myself. 你可以检查一下,虽然我自己没有这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM