I am getting failures when trying to download a blob from storage account to RHEL8 virtial machine. How can this be resolved?

FRED M 1 Reputation point
2022-04-25T15:56:32.9+00:00

I am running this command on RHEL8 vm

az storage blob download-batch -d "/tmp/" --pattern "openldap-2.6.0.tgz" -s "binaries" --account-name "<strg-acc-name>" --account-key "<strg-acc-key>"

and I am getting this error:

The command failed with an unexpected error. Here is the traceback:
'BlobServiceClient' object has no attribute 'exists'
Traceback (most recent call last):
File "/lib64/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 658, in execute
raise ex
File "/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 721, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 713, in _run_job
return cmd_copy.exception_handler(ex)
File "/lib64/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/init.py", line 385, in new_handler
first(ex)
File "/lib64/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/init.py", line 385, in new_handler
first(ex)
File "/lib64/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/_exception_handler.py", line 17, in file_related_exception_handler
raise ex
File "/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 692, in _run_job
result = cmd_copy(params)
File "/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 328, in call
return self.handler(*args, **kwargs)
File "/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/lib64/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 363, in storage_blob_download_batch
source_blobs = collect_blobs(client, source_container_name, pattern)
File "/lib64/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/util.py", line 16, in collect_blobs
return [name for (name, _) in collect_blob_objects(blob_service, container, pattern)]
File "/lib64/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/util.py", line 16, in <listcomp>
return [name for (name, _) in collect_blob_objects(blob_service, container, pattern)]
File "/lib64/az/lib/python3.6/site-packages/azure/cli/command_modules/storage/util.py", line 31, in collect_blob_objects
if blob_service.exists(container, pattern):
AttributeError: 'BlobServiceClient' object has no attribute 'exists'

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,449 questions
{count} votes

3 answers

Sort by: Most helpful
  1. AK 11 Reputation points
    2022-04-29T10:49:54.297+00:00

    Hi @FRED M and @Tim H ,

    I have found the alternate solution. When we use the download-batch command, It checks the file existence.
    So, instead of using download-batch, I used the single file download command:

    az storage blob download -f /path/to/file -c mycontainer -n MyBlob

    The above command downloads the one file at a time. Now, It is able to download the file from storage.
    For more details about this command: https://learn.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest#az-storage-blob-download

    2 people found this answer helpful.

  2. Tim H 6 Reputation points
    2022-04-29T14:24:41.837+00:00

    az storage blob download worked after all.

    Before:
    az storage blob download-batch --account-name accountName --destination . --source containerName --pattern "packages/somefile.zip" --account-key "secret_key"

    After:
    az storage blob download --account-name accountName --file "somefile.zip" --container containerName --name "packages/somefile.zip" --account-key "secret_key"

    BTW, this is a known issue fixed in a recent Azure CLI release: https://github.com/Azure/azure-cli/issues/21966

    1 person found this answer helpful.
    0 comments No comments

  3. SaiKishor-MSFT 17,201 Reputation points
    2022-04-27T18:43:22.94+00:00

    @FRED M Thank you for contacting Microsoft Q&A regarding your error 'BlobServiceClient' object has no attribute 'exists'.

    I would encourage you to reach out to Azure Support regarding this directly so they can troubleshoot the same as this might need a deeper investigation. Thank you!

    0 comments No comments