首页 > 解决方案 > 在 Azure DevOps 服务中运行构建管道以部署云服务(经典)时出现“序列不包含元素错误”

问题描述

我创建了一个 Azure 经典类型的服务连接。有什么我想念的吗?

然后,我使用此 Azure 经典服务连接将云服务部署到 Azure。

Azure Deployment: D:\a\1\a\*.cspkg

View raw log

Starting: Azure Deployment: D:\a\1\a\*.cspkg
----------------------------------------------------------------
Task         : Azure Cloud Service deployment
Description  : Deploy an Azure Cloud Service
Version      : 1.175.2
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cloud-powershell-deployment
----------------------------------------------------------------
Import-Module -Name C:\Modules\azure_2.1.0\Azure\2.1.0\Azure.psd1 -Global

Import-Module -Name C:\Modules\azurerm_2.1.0\AzureRM\2.1.0\AzureRM.psd1 -Global

##[warning]The names of some imported commands from the module 'AzureRM.Websites' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the 

Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

Import-Module -Name C:\Modules\azurerm_2.1.0\AzureRM.Profile\2.1.0\AzureRM.Profile.psm1 -Global

Add-AzureAccount -Credential System.Management.Automation.PSCredential

##[error]Sequence contains no elements
-
##[error]There was an error with the Azure credentials used for the deployment.
-
Finishing: Azure Deployment: D:\a\1\a\*.cspkg

PS:我使用经典编辑器来创建管道,而不是 YAML 构建。

标签: azure-devopsazure-cloud-services

解决方案


通过下面的错误信息,问题就很明显了。 喜欢这张照片。

在此处输入图像描述

##[error]Sequence contains no elements

##[error]There was an error with the Azure credentials used for the deployment.

您需要$cred通过以下脚本。(有一些限制,有关更多详细信息,请阅读相关帖子。)

$username = "**.com"
$password = "***"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
Add-AzureRmAccount -Credential $cred

相关文章

1. Visual Studio Team Services:序列不包含任何元素

2. Add-AzureRmAccount : 序列不包含任何元素


推荐阅读