question

FREDM-6385 avatar image
0 Votes"
FREDM-6385 asked TimH-4734 answered

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

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
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @FREDM-6385,

I am also getting the same error.
Please Post the answer, if you find the solution.

Thank you.

0 Votes 0 ·

Exact same issue here. Nothing changed in the command for the last two years. Stopped working.

0 Votes 0 ·

I found the alternate solution. Please check Answers section

0 Votes 0 ·
SaiKishor-MSFT avatar image
0 Votes"
SaiKishor-MSFT answered

@FREDM-6385 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!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AK-8802 avatar image
2 Votes"
AK-8802 answered AK-8802 commented

Hi @FREDM-6385 and @TimH-4734,

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://docs.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest#az-storage-blob-download




· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the reply.

Unless I am missing something, I don't think this will work for me, as I have thousands of blobs in my container, hence, the need for batch download.

0 Votes 0 ·

Then try with azCopy or AzCopy v10 command. You can copy the entire directory to your location.

0 Votes 0 ·
TimH-4734 avatar image
1 Vote"
TimH-4734 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.