Azure powershell Move-AzureDeployment - error: HttpRequestException

Azure powershell Move-AzureDeployment - error: HttpRequestException

我们在 Azure 管道中使用 powershell 进行了云服务(经典)交换,该交换运行了一整年,由之前的员工设置,但现在失败并出现错误:

Move-AzureDeployment : An error occurred while sending the request.
At D:\a\_temp\blahblahblah.ps1:8 char:1
+ Move-AzureDeployment -ServiceName $servicename
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Move-AzureDeployment], HttpRequestException
    + FullyQualifiedErrorId : System.Net.Http.HttpRequestException,Microsoft.WindowsAzure.Commands.ServiceManagement.H 
   ostedServices.MoveAzureDeploymentCommand

实际作业任务是使用 PowerShell 脚本设置为内联,并将错误操作设置为停止。实际脚本:

$subid = 'blah-blah-blah-blah'
$servicename = "blahblahblah"

Select-AzureSubscription -SubscriptionId $subid

Move-AzureDeployment -ServiceName $servicename
$service = Get-AzureDeployment -ServiceName $servicename -Slot Production

Start-Sleep -s 300

Remove-AzureDeployment -ServiceName $servicename -Slot "Staging" -Force

我确定这可能是管理证书已过期的服务连接,但我有一个有效的工作连接,发现它的设置与另一个正在工作的类似 pipeline/service 连接完全一样。

所以问题有两个,更新后的 SSL 和 PowerShell 版本问题。为了处理 SSL 问题,我将这一行添加到我们的内联脚本的顶部:

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

对于 PowerShell 问题,它需要更改为管道的 Azure PowerShell 应用程序,因此我们可以回滚到特定任务版本和 4.2.1 PowerShell 版本,如此答案所示:

Programmatically Swap Staging Slot to Production Slot in Azure Cloud Service

这可能是目前更换云服务(经典版)的唯一方法。有点烦人的 Azure 推了这个经典服务,却从来没有妥善维护它。