1
votes

We have a Cloud Service (Classic) swap using powershell in Azure pipelines that has worked all year, setup by a previous employee and now it is failing with error:

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

The actual job task is using PowerShell Script set as inline with Error action as Stop. The actual script:

$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

I was sure this was maybe a Service connection with Management Certificate expired but I have one valid working and found it is setup exactly like another similar pipeline/service connection that is working.

1
please add -debug at the ned of the command Move-AzureDeployment to get the detailed error message。Jim Xu
@JimXu that did not show anything new.Shane
Hi @Shane, which agent are you using? I have tested it and it works.Vito Liu
Hi @VitoLiu-MSFT I got it working and added my answer bellow. It is about changing the PowerShell app used in pipelines, seems it might be needed due to AzModule and AzureRMModule's having their own PowerShell versions and installed, conflicting with the methods we use in the script, as well as SSL configuration that had changed. That might be due to the agent version, not sure what changed that.Shane
Hi @Shane, Thanks for your sharing, you could accept your answer. In this case, others could directly find the useful solution. ThanksVito Liu

1 Answers

1
votes

So the issue was two things, SSL and PowerShell version issues after updates. To deal with SSL issues I added this line to the top of our inline script:

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

And for the PowerShell issue it required changing to the Azure PowerShell app for pipelines, so we could roll back to a specific task version and the 4.2.1 PowerShell Version as seen in this answer:

Programmatically Swap Staging Slot to Production Slot in Azure Cloud Service

enter image description here

This might be the only way to swap a Cloud Service (Classic) these days. A little annoying Azure pushed this classic service and never properly maintained it.