ERROR: The command failed with an unexpected error az storage blob download
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.
@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
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 Can you provide debug log by adding --debug? What's the CLI version you are using?