azure-devops - 在管道中使用 AzureCLI 任务时出错
问题描述
我的 Azure 管道使用Azure CLI任务
- task: AzureCLI@2
inputs:
azureSubscription: '...'
scriptType: pscore
scriptLocation: 'inlineScript'
inlineScript: |
containers=$(az storage container list --connection-string '...')
任务失败并出现以下错误:
The term 'containers=$(az storage container list --connection-string '...')' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\a\_temp\azureclitaskscript1582829158619_inlinescript.ps1:1 char:1
+ containers=$(az storage container list --connection-string 'DefaultEn ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (containers=$(az sto\u2026ame}" --output tsv):String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
##[error]Script failed with error: Error: The process 'C:\Program Files\PowerShell\6\pwsh.exe' failed with exit code 1
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" account clear"
Finishing: AzureCLI
我不知道为什么会这样。
解决方案
在这种情况下,问题是由于语法错误造成的:
$containers=$(az storage container list --connection-string '...')
推荐阅读
- mysql - 我有一个包含非英文单词的文本文件,我需要将它放入 mysql 我该怎么做?
- java - 将 Kotlin 算法翻译成 Java 代码
- paypal - 使用 PayPal 订阅 API 收取税款
- c++ - 如何通过 C++ 部分获取文件中的行
- python - 错误的列表输出超出预期
- linux - 在 FTP 命令模式下,如何重定向命令行以及使用 shell 脚本使用此处文档让 ftp 命令读取标准输入时的结果
- python - 如何在python中生成函数n次并计算数字?
- android - 从活动返回作为深层链接导航目的地
- stack - 关于后缀转换的说明
- stm32 - Yocto 变量未定义,但使用 _ 运算符设置