Skip to content

storage blob download-batch fails with "[Errno 20] Not a directory" #32427

@cbare

Description

@cbare

Describe the bug

The download-batch command fails when downloaded nested subfolders from Data Lake Storage. Folders, in this case, are represented as zero-byte blobs. For example,

az storage blob download-batch -s https://sciencelibrarieswestus2.blob.core.windows.net/external-data-share -d stanford --pattern stanford/*

When you download nested subfolders, a zero byte file gets written to the destination on local disk, called dataset_a in my case. Since that's not a directory, you get the following error when you try to write the files inside that dataset_a subfolder.

[Errno 20] Not a directory: 'stanford/stanford/dataset_a/dataset_a_Summary.csv'

You can work around by creating the local directory structure manually and downloading the leave files only, but that's quite tedious.

Related command

az storage blob download-batch

Errors

[Errno 20] Not a directory

Issue script & Debug output

Didn't get a chance to do this.

Expected behavior

make directories instead of zero-byte files.

Environment Summary

az --version
azure-cli 2.75.0

core 2.75.0
telemetry 1.1.0

Dependencies:
msal 1.33.0b1
azure-mgmt-resource 23.3.0

Python location '/opt/az/bin/python3'
Config directory '/home/christopherbare/.azure'
Extensions directory '/home/christopherbare/.azure/cliextensions'

Python (Linux) 3.12.10 (main, Jun 24 2025, 10:15:18) [GCC 13.3.0]

Additional context

No response

Metadata

Metadata

Labels

Auto-AssignAuto assign by botAuto-ResolveAuto resolve by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamSimilar-IssueStorageaz storageact-codegen-extensibility-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions