Azure-cli: ERROR: The command failed with an unexpected error az storage blob download

Created on 14 Nov 2019  路  6Comments  路  Source: Azure/azure-cli

I want to download a file from blob storage to be able to use it in a later task
and I am using az storage blob download and it is failing with:

az : ERROR: The command failed with an unexpected error. Here is the traceback:
At D:a_tempazureclitaskscript1573734549802_inlinescript.ps1:2 char:1

  • az storage blob download -c mycontainername -f d:a\1a/download/output.js ...
  • ~~~~~~~~~~~~~~~~~

    • CategoryInfo : NotSpecified: (ERROR: The comm... the traceback::String) [], RemoteException

    • FullyQualifiedErrorId : NativeCommandError

[error]Script failed with error: Error: The process 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1

To Reproduce
Steps to reproduce the behavior.
steps:

  • task: AzureCLI@2
    displayName: Azure CLI
    inputs:
    azureSubscription: AzureSubscription
    scriptType: ps
    scriptLocation: inlineScript
    inlineScript: |
    az login --service-principal -u $(serviceprincipal) -p $(servicepass) --tenant $(tenant)
    az storage blob download -c mycontainername -f $(Build.ArtifactStagingDirectory)/download/output.json -n myfile.json --account-name accountname --account-key $(accesskey) --verbose

Expected behavior
I want it to download the file into the specified path or give me some more information regarding the failure. Even when using --verbose I don't get more details

Environment summary
az --version shows 2.0.76
pool:
vmImage: 'windows-latest'

When I run this command locally it works fine so I don't think it is a auth issue here.

Storage

All 6 comments

@Juliehzl please take a look.

Hi @saroup, you should use --debug in your command to get more information for your command.
Could you please show me more information for your error?

Synced with @saroup, she will try to put all Azure CLI commands with "--debug" option in a ps1 file and run it locally to see if it still has issue or not. If there is no issue in that try, then the issue is probably related to Azure DevOps.

cc @Juliehzl

@saroup , I'll close this issue because you can resolve this issue by "removing the login piece" as we discussed in Teams. We'll also to see if we can improve our logging for --verbose or --debug.

cc @yonzhan

@saroup , I'll close this issue because you can resolve this issue by "removing the login piece" as we discussed in Teams. We'll also to see if we can improve our logging for --verbose or --debug.

cc @yonzhan

What exactly did you discuss in Teams? We're facing a similar issue

@alessandromuresan ,

Here is the script that had issue we talked in Teams, and after we remove "az login --service-principal -u $(serviceprincipal) -p $(servicepass) --tenant $(tenant)", the issue was gone.

  • task: AzureCLI@2
    displayName: Azure CLI
    inputs:
    azureSubscription: blob
    scriptType: ps
    scriptLocation: inlineScript
    inlineScript: |
    az login --service-principal -u $(serviceprincipal) -p $(servicepass) --tenant $(tenant)
    az storage blob download -c xxx -f $(System.DefaultWorkingDirectory)/merged.json -n merged.json --account-name xxx --account-key $(accesskey) --debug
Was this page helpful?
0 / 5 - 0 ratings