`az storage blob directory` failures return exit code 0

See original GitHub issue

When running a az storage blob directory command which results in a failure, the exit code of the command is 0, meaning it was successful, not 1, which it should be on failure.

I’ve tried this on 2 commands: Uploading a file:

[user@localhost ~]$ az storage blob directory upload --account-name mystorageacct --container mycontainer --destination-path / --source testfile
INFO: Scanning...
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support

Job 9s9a9979-7838-4a42-6f79-5b150ff07611 has started
Log file is located at: /home/user/.azcopy/9s9a9979-7838-4a42-6f79-5b150ff07611.log

INFO: Authentication failed, it is either not correct, or expired, or does not have the correct permission -> github.com/Azure/azure-storage-blob-go/azblob.newStorageError, /home/vsts/go/pkg/mod/github.com/!azure/azure-storage-blob-go@v0.10.0/azblob/zc_storage_error.go:42
===== RESPONSE ERROR (ServiceCode=AuthorizationFailure) =====
Description=This request is not authorized to perform this operation.
RequestId:5ec4200c-f01e-0058-451d-d803ae000000
Time:2021-11-12T23:34:30.4774040Z, Details: 
   Code: AuthorizationFailure
   PUT https://mystorageacct.blob.core.windows.net/mycontainer//testfile?se=2021-11-13t23%3A34%3A30z&sig=-REDACTED-&sp=rwdlacup&srt=sco&ss=b&sv=2018-03-28&timeout=901
   Content-Length: [10]
   User-Agent: [AzCopy/10.5.0 Azure-Storage/0.10 (go1.13; linux)]
   X-Ms-Blob-Cache-Control: []
   X-Ms-Blob-Content-Disposition: []
   X-Ms-Blob-Content-Encoding: []
   X-Ms-Blob-Content-Language: []
   X-Ms-Blob-Content-Md5: []
   X-Ms-Blob-Content-Type: [text/plain; charset=utf-8]
   X-Ms-Blob-Type: [BlockBlob]
   X-Ms-Client-Request-Id: [3acf187d-c772-4474-5c7e-2d4ee178fe73]
   X-Ms-Version: [2019-02-02]
   --------------------------------------------------------------------------------
   RESPONSE Status: 403 This request is not authorized to perform this operation.
   Content-Length: [246]
   Content-Type: [application/xml]
   Date: [Fri, 12 Nov 2021 23:34:29 GMT]
   Server: [Microsoft-HTTPAPI/2.0]
   X-Ms-Client-Request-Id: [3acf187d-c772-4474-5c7e-2d4ee178fe73]
   X-Ms-Error-Code: [AuthorizationFailure]
   X-Ms-Request-Id: [5ec4200c-f01e-0058-451d-d803ae000000]



INFO: azcopy: A newer version 10.13.0 is available to download

0.0 %, 0 Done, 0 Failed, 1 Pending, 0 Skipped, 1 Total, 


Job 9s9a9979-7838-4a42-6f79-5b150ff07611 summary
Elapsed Time (Minutes): 0.0334
Number of File Transfers: 1
Number of Folder Property Transfers: 0
Total Number of Transfers: 1
Number of Transfers Completed: 0
Number of Transfers Failed: 1
Number of Transfers Skipped: 0
TotalBytesTransferred: 0
Final Job Status: Cancelled

[user@localhost ~]$ $?
0: command not found

and Listing a directory:

[user@localhost ~]$ az storage blob directory list --account-name mystorageacct --container-name mycontainer --directory-path /

You do not have the required permissions needed to perform this operation.
Depending on your operation, you may need to be assigned one of the following roles:
    "Storage Blob Data Contributor (Preview)"
    "Storage Blob Data Reader (Preview)"
    "Storage Queue Data Contributor (Preview)"
    "Storage Queue Data Reader (Preview)"

If you want to use the old authentication method and allow querying for the right account key, please use the "--auth-mode" parameter and "key" value.
                
[user@localhost ~]$ $?
0: command not found

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
achilles-portarinoscommented, Oct 7, 2022

It’s reported for 11 months. Then I’m stunned this bug is marked as a feature request.

“az storage fs directory” seems to have replaced this (there are some warnings about deprecation popping up. This seems to throw when failing. I personally used this instead. Hope this helps.

0reactions
msftbot[bot]commented, Oct 8, 2022

Thank you for your feedback. This has been routed to the support team for assistance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Blob Storage error codes - Microsoft Learn
Error code HTTP status code User message BlobAlreadyExists Conflict (409) The specified blob already exists. BlobNotFound Not Found (404) The specified blob does not exist. ContainerAlreadyExists...
Read more >
Filter blob by tags using SAS-token in azure CLI fails with ...
I tried to confirm if the sas token provided is valid by running below command and it does execute fine returning a json....
Read more >
azure-cli-storage 2.4.3 - PyPI
2.4.0. BREAKING CHANGE: storage blob delete : remove the return result of ... Converted 'show' commands that were missed from failing with exit...
Read more >
Error from az storage blob upload-batch command in Azure ...
az storage blob upload-batch -s /home/vsts/work/r1/a/www2site/xxxxxxx -d '$web' ... we get the following error and it fails to upload anymore files.
Read more >
Documentation - Rclone
Rclone syncs a directory tree from one storage system to another. ... By default, rclone will exit with return code 0 if there...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found