azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

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

Open saroup opened this issue 7 years ago • 8 comments

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_temp\azureclitaskscript1573734549802_inlinescript.ps1:2 char:1

  • az storage blob download -c mycontainername -f d:\a\1\a/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.

saroup avatar Nov 14 '19 13:11 saroup

@Juliehzl please take a look.

fengzhou-msft avatar Nov 15 '19 02:11 fengzhou-msft

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?

Juliehzl avatar Nov 24 '19 13:11 Juliehzl

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

jsntcy avatar Nov 26 '19 05:11 jsntcy

@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

jsntcy avatar Dec 02 '19 01:12 jsntcy

@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 avatar Mar 12 '20 17:03 alessandromuresan

@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

jsntcy avatar Mar 13 '20 02:03 jsntcy

Why is this an issue with service principle though? We are using cli as powershell from devops/tfs and it's a better choice to use the service principle we have created instead of an account key- For me, my issue arises when using az storage fs file download along with service principle

kaburkett avatar Sep 09 '21 20:09 kaburkett

@kaburkett Can you provide debug log by adding --debug? What's the CLI version you are using?

evelyn-ys avatar Sep 10 '21 02:09 evelyn-ys