且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将SSL证书添加到中使用PowerShell蔚蓝的网站?

更新时间:2023-11-25 08:12:34

据我所知在Azure PowerShell命令并不在我能找到的时刻提供这种功能。正如你指出的跨平台命令行工具一样。既然你不想给XPlat-CLI工具添加到您可以使用引擎盖下的XPlat-CLI工具做了什么部署机器:对REST API的网站管理直接调用。

请注意,你需要找出网络空间网站驻留在等,你可以使用Invoke-WebRequest的拨打这个电话,让你可以验证你得到200回响应。或者你可以使用Invoke-RESTMethod为好,但只会返回一个XML文档(响应的内容)。将Invoke-WebRequest的为您提供多一点的控制和访问完整的响应对象。

借助微软Azure管理库(其中PowerShell命令坐在上面的)有一个网站管理一块吧。之一的操作的是一个更新到一个站点和包括WebSiteUpdateParameters与SSLCertificates属性对象。您可以检查到该为好,虽然我不是这个做自己所。

I am working on automatic deployment + azure. I'm at the point where i'm adding an ssl cert to the website. Does anyone know how to use PowerShell to upload an SSL certificate to a website using the PowerShell command (Add - Get - Set based commands)? 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

As far as I know the Azure PowerShell cmdlets do not offer this capability at the moment that I could find. 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.

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. Or you could use the Invoke-RESTMethod as well, but that would only return an XML document (the contents of the response). The Invoke-WebRequest provides you a little more control and access to the full response object.

The Microsoft Azure Management Libraries (which the PowerShell cmdlets sit on top of) has a Web Site Management piece to it. One of the operations is an update to a site and that includes a WebSiteUpdateParameters object with a SSLCertificates property. You may check into that as well, though I've not done this myself.