Skip to content

az storage blob list --delimiter parameter value is ignored #18393

@AlexandreArpin

Description

@AlexandreArpin

Describe the bug

When using the --delimiter parameter for az storage blob list, the value of the delimiter parameter is ignored and always falls back to /

Command Name
az storage blob list

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Create a storage account with two blobs cats/garfield-1.png and cats/garfield-2.png
  • az storage blob list -c <container-name> --delimiter 'field' --account-name <account-name>

Expected Behavior

It should return 1 blob prefix object of value cats/garfield

Actual Behavior

It returns 1 blob prefix object of value cats/

alexandre@Azure:~$ az storage blob list -c <redacted> --delimiter 'field' --account-name <redacted> --query '[].{Name:name}' --output table

Name
------------
cats/

The issue seems to be in src\azure-cli\azure\cli\command_modules\storage\operations\blob.py.

def list_blobs(client, delimiter=None, include=None, marker=None, num_results=None, prefix=None,
               show_next_marker=None, **kwargs):
    from ..track2_util import list_generator

    if delimiter:
        generator = client.walk_blobs(name_starts_with=prefix, include=include, results_per_page=num_results, **kwargs)
    else:
        generator = client.list_blobs(name_starts_with=prefix, include=include, results_per_page=num_results, **kwargs)

I believe it's just because the delimiter parameter is not forwarded/passed to the client.walk_blobs method which has a default delimiter value of /.

Environment Summary

Linux-5.4.0-1048-azure-x86_64-with-debian-10.2 (Cloud Shell)
Python 3.6.10
Installer: DEB

azure-cli 2.24.2

Extensions:
ai-examples 0.2.5
ssh 0.1.5

Additional Context

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions