我正在 "Sequence contains no elements error" 而 运行 Azure DevOps 服务中的构建管道部署云服务(经典)
I am getting the "Sequence contains no elements error" while running a build pipeline in Azure DevOps services to deploy a cloud service (classic)
我已经创建了一个 Azure 经典类型的服务连接。有什么我想念的吗?
然后我使用这个 Azure 经典服务连接将云服务部署到 Azure。
Azure Deployment: D:\a\a\*.cspkg
View raw log
Starting: Azure Deployment: D:\a\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.1.0\Azure.psd1 -Global
Import-Module -Name C:\Modules\azurerm_2.1.0\AzureRM.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.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\a\*.cspkg
PS:我正在使用经典编辑器创建管道而不是 YAML 构建。
通过下面的报错信息,问题就很明显了。喜欢这张图
##[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: Sequence contains no elements
##[error]There was an error with the Azure credentials used for the deployment.
您可以更改为使用 Certificate Based
作为验证方法。
要使用 Certificate Based
方法,您可以使用以下脚本创建 .cer 文件。
$cert = New-SelfSignedCertificate -DnsName yourdomain.cloudapp.net -CertStoreLocation "cert:\LocalMachine\My" -KeyLength 2048 -KeySpec "KeyExchange"
$password = ConvertTo-SecureString -String "your-password" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath ".\my-cert-file.pfx" -Password $password
Export-Certificate -Type CERT -Cert $cert -FilePath .\my-cert-file.cer
那么你可以得到 upload certificate with the management portal.
同时,您可以通过.cer文件获得Public密钥。
此密钥用于服务连接。
您可以参考了解问题的可能原因
我已经创建了一个 Azure 经典类型的服务连接。有什么我想念的吗?
然后我使用这个 Azure 经典服务连接将云服务部署到 Azure。
Azure Deployment: D:\a\a\*.cspkg
View raw log
Starting: Azure Deployment: D:\a\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.1.0\Azure.psd1 -Global
Import-Module -Name C:\Modules\azurerm_2.1.0\AzureRM.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.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\a\*.cspkg
PS:我正在使用经典编辑器创建管道而不是 YAML 构建。
通过下面的报错信息,问题就很明显了。喜欢这张图
##[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: Sequence contains no elements
##[error]There was an error with the Azure credentials used for the deployment.
您可以更改为使用 Certificate Based
作为验证方法。
要使用 Certificate Based
方法,您可以使用以下脚本创建 .cer 文件。
$cert = New-SelfSignedCertificate -DnsName yourdomain.cloudapp.net -CertStoreLocation "cert:\LocalMachine\My" -KeyLength 2048 -KeySpec "KeyExchange"
$password = ConvertTo-SecureString -String "your-password" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath ".\my-cert-file.pfx" -Password $password
Export-Certificate -Type CERT -Cert $cert -FilePath .\my-cert-file.cer
那么你可以得到 upload certificate with the management portal.
同时,您可以通过.cer文件获得Public密钥。
此密钥用于服务连接。
您可以参考