azure-devops - 在 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 构建。
解决方案
通过下面的错误信息,问题就很明显了。 喜欢这张照片。
##[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
相关文章
推荐阅读
- ios - 显示 int 数组列表的优雅方式
- javascript - 当用户在Vue中注销时重定向到登录页面
- javascript - 从 json 文件中读取未定义的变量
- python - PySide2/PyQt5中如何更改QMediaPlayer的音频输出设备
- python - 使用数据加载器对异常进行批处理
- c# - 在 LINQ Where(x => f(x) > y) 和 OrderBy(f) 中使用相同的委托和 SQL 编译
- python - 如何从 Python 中的控制台文本中保存变量?
- ion-slides - 如何更改分页项目符号大小
- python - 如何使用 docker 安装 bob python 工具包?
- android - 如何在 Android Wear 中将旋转输入添加到 ScrollView