首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Azure DevOps Powershell脚本无法创建SSL/TLS安全通道

Azure DevOps Powershell脚本无法创建SSL/TLS安全通道
EN

Stack Overflow用户
提问于 2020-09-17 14:16:21
回答 7查看 3.8K关注 0票数 10

问题:

如果我从Get-AzureDeployment(also 管道中的'Azure Powershell‘任务调用命令DevOps Get-AzureService),我将得到:’请求被中止:无法创建SSL/TLS安全通道.‘。

简介:

  • 我使用Azure DevOps将Azure服务(经典)部署到Azure中
  • 'Azure Powershell‘任务一直在工作,但是没有任何改变,它就停止工作了。
  • 我还将证书(由DevOps使用)导入到我的pc上(由),并尝试运行相同的powershell脚本,并且每个都正常工作,因此我希望在DevOps中出现问题。

DevOps连接:

  • 我在Azure DevOps中创建了“服务连接”以连接到Azure
  • 服务连接类型为“Azure classic”(因为“Azure Resource”不是用于“Cloud服务经典”)
  • “Azure经典服务连接”的增强方法是“基于证书的”。
  • 我使用了由“发布设置文件”生成的证书作为蔚蓝订阅。证书由azure放置到>Management证书中(有效期为2021年年中)。
  • 我使用这个服务连接将应用程序 (Cloud经典版)部署到Azure 中,没有问题--(由DevOps任务‘AzureCloudServiceDeployment’),而只是'Azure‘任务开始失败。

这一切都工作了3个月,然后停止工作,因为任何原因。奇怪的是,当我使用DevOps来找出问题所在时,任务曾经成功地运行过,但是当我再次尝试时,我再次得到了错误。

我有两个日志,从成功的电话和失败的电话。2506行原木是相同的,变化在这一行之后。

我可以寄给你们两个完整的日志,但我不想把这么长的日志放在这里。

成功尝试:

代码语言:javascript
运行
复制
VERBOSE: 8:31:40 AM - Begin Operation: Get-AzureDeployment
VERBOSE: 8:31:42 AM - Completed Operation: Get-AzureDeployment
... some other info about the deployment in slot

从失败调用中登录:

代码语言:javascript
运行
复制
VERBOSE: 9:53:39 AM - Begin Operation: Get-AzureDeployment
##[debug]Caught exception from task script.
##[debug]Error record:
##[debug]Get-AzureDeployment : An error occurred while sending the request.
##[debug]At D:\a\r1\a\_Tools\Powershell\cloud-service_swap-slot.ps1:14 char:15
##[debug]+ ... eployment = Get-AzureDeployment -Slot "Staging" -ServiceName $CloudSe ...
##[debug]+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##[debug]    + CategoryInfo          : CloseError: (:) [Get-AzureDeployment], HttpRequestException
##[debug]    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureDeploymentComma    nd
##[debug] 
##[debug]Script stack trace:
##[debug]at <ScriptBlock>, D:\a\r1\a\_Tools\Powershell\cloud-service_swap-slot.ps1: line 14
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, D:\a\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\3.171.2\AzurePowerShell.ps1: line 145
##[debug]at <ScriptBlock>, D:\a\_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\3.171.2\AzurePowerShell.ps1: line 141
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, <No file>: line 22
##[debug]at <ScriptBlock>, <No file>: line 18
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
##[debug]   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
##[debug]   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
##[debug]   --- End of inner exception stack trace ---
##[debug]   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
##[debug]   at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
##[debug]   at Microsoft.WindowsAzure.Management.Compute.DeploymentOperationsExtensions.GetBySlot(IDeploymentOperations operations, String serviceName, DeploymentSlot deploymentSlot)
##[debug]   at Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientActionNewSM[TResult](Object input, String operationDescription, Func`1 action, Func`3 contextFactory)
##[error]An error occurred while sending the request.
##[debug]Processed: ##vso[task.logissue type=error]An error occurred while sending the request.
##[debug]Processed: ##vso[task.complete result=Failed]

在这两种日志中,我还可以找到将Azure帐户添加到Powershell中的如下内容:

代码语言:javascript
运行
复制
##[debug]Added certificate to the certificate store.
##[command]Set-AzureSubscription -SubscriptionName PXX -SubscriptionId XXXXXX01-09f5-4703-bcc9-6ff914XXXXXX -Certificate ******** -Environment AzureCloud 
##[command]Select-AzureSubscription -SubscriptionId XXXXXX01-09f5-4703-bcc9-6ff914XXXXXX
##[debug]Leaving Initialize-Azure.
## Initializing Azure Complete 

(我用X替换了一些字符串)

YAML中有Powershell任务:

代码语言:javascript
运行
复制
steps:
- task: AzurePowerShell@3
  displayName: 'Swap slots'
  inputs:
    azureConnectionType: ConnectedServiceName
    azureClassicSubscription: 'PXX subscription'
    ScriptPath: '$(System.DefaultWorkingDirectory)/_Tools/Powershell/cloud-service_swap-slot.ps1'
    ScriptArguments: '-CloudServiceName $(CloudServiceName)'
    FailOnStandardError: true
    azurePowerShellVersion: LatestVersion

以及用于交换从本地pc (具有相同证书)但在DevOps中失败的插槽的Powershell脚本:

代码语言:javascript
运行
复制
[CmdletBinding(PositionalBinding=$True)]
Param(
    [Parameter(Mandatory = $true)]
    [String]$CloudServiceName              # required
)

# Check if Windows Azure Powershell is avaiable 
if ((Get-Module -ListAvailable Azure) -eq $null) 
{ 
    throw "Windows Azure Powershell not found! Please install from http://www.windowsazure.com/en-us/downloads/#cmd-line-tools" 
} 
 
# VIP Swap
$Deployment = Get-AzureDeployment -Slot "Staging" -ServiceName $CloudServiceName #It's failing here
if ($Deployment -ne $null -AND $Deployment.DeploymentId  -ne $null) 
{ 
     Write-Output ("Current Status of staging in {0}" -f $CloudServiceName); 
     Write-Host ($Deployment | Select-Object -Property * -ExcludeProperty Configuration,RolesConfiguration | Format-List | Out-String);

     $MoveStatus = Move-AzureDeployment -ServiceName $CloudServiceName 
     Write-Output ("Vip swap of {0} status: {1}" -f $CloudServiceName, $MoveStatus.OperationStatus)     
}else 
{ 
     Write-Output ("There is no deployment in staging slot of {0} to swap." -f $CloudServiceName) 
} 

有没有人像我一样有同样的经历?问题在哪里?

#更新

我尝试在脚本开始时添加这个安全协议设置,但也有相同的错误。

代码语言:javascript
运行
复制
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
EN

Stack Overflow用户

发布于 2020-09-22 06:58:22

我也有同样的问题,并尝试了所有这些,对我来说,只有当我在Initialize部分之后添加了以下内容时,它才能工作:“subscription my订阅id -CurrentStorageAccountName存储名”

票数 1
EN
查看全部 7 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63940041

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档