Error using the AzureCLI task in pipeline

ぐ巨炮叔叔 提交于 2020-03-25 16:07:20

问题


My Azure pipeline makes use of the Azure CLI task

- task: AzureCLI@2
    inputs:
      azureSubscription: '...'
      scriptType: pscore
      scriptLocation: 'inlineScript'
      inlineScript: |
        containers=$(az storage container list --connection-string '...')

The task fails with this error:

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

I can't figure out why it happens.


回答1:


in this case the issue was due to a syntax mistake:

$containers=$(az storage container list --connection-string '...')


来源:https://stackoverflow.com/questions/60449605/error-using-the-azurecli-task-in-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!