Skip to content

az storage blob upload does not allow for uploading empty blob with --data #31852

@cecheta

Description

@cecheta

Describe the bug

The command az storage blob upload should allow you to upload an empty file to blob storage, using --data ''. However, it gives this error:

usage error: please specify one of --file and --data to upload.

Related command

az storage blob upload

Errors

usage error: please specify one of --file and --data to upload.

Issue script & Debug output

~ az storage blob upload --account-name myaccount --container-name mycontainer --name file.txt --data '' --debug
cli.knack.cli: Command arguments: ['storage', 'blob', 'upload', '--account-name', 'myaccount', '--container-name', 'mycontainer', '--name', 'file.txt', '--data', '', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7f2b6822ca40>, <function OutputProducer.on_global_arguments at 0x7f2b67f8cb80>, <function CLIQuery.on_global_arguments at 0x7f2b67fbe0c0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'storage': ['azure.cli.command_modules.storage']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: storage                   0.151        60       275
cli.azure.cli.core: Total (1)                 0.151        60       275
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: Total (0)                 0.000         0         0
cli.azure.cli.core: Loaded 60 groups, 275 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : storage blob upload
cli.azure.cli.core: Command table: storage blob upload
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f2b66d684a0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/cecheta/.azure/commands/2025-07-21.17-01-46.storage_blob_upload.119686.log'.
az_command_data_logger: command args: storage blob upload --account-name {} --container-name {} --name {} --data {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f2b66db3b00>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7f2b66db3ba0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7f2b66db3ce0>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x7f2b66db3d80>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f2b67f8cc20>, <function CLIQuery.handle_query_parameter at 0x7f2b67fbe160>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f2b66db3c40>]
Argument '--data' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
cli.azure.cli.command_modules.storage._validators: Try to get storage auth_mode value from environment variables or config file.
cli.azure.cli.command_modules.storage._validators: Try to get storage connection_string value from environment variables or config file.
cli.azure.cli.command_modules.storage._validators: Try to get storage key value from environment variables or config file.
cli.azure.cli.command_modules.storage._validators: Try to get storage sas_token value from environment variables or config file.
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/linuxbrew/.linuxbrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 654, in execute
    self._validation(expanded_arg)
  File "/home/linuxbrew/.linuxbrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/invocation.py", line 113, in _validation
    self._validate_arg_level(parsed_ns)
  File "/home/linuxbrew/.linuxbrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 925, in _validate_arg_level
    validator(**self._build_kwargs(validator, ns))
  File "/home/linuxbrew/.linuxbrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/command_modules/storage/_validators.py", line 2315, in validate_upload_blob
    raise InvalidArgumentValueError("usage error: please specify one of --file and --data to upload.")
azure.cli.core.azclierror.InvalidArgumentValueError: usage error: please specify one of --file and --data to upload.

cli.azure.cli.core.azclierror: usage error: please specify one of --file and --data to upload.
az_command_data_logger: usage error: please specify one of --file and --data to upload.
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f2b66d68720>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 0.573 seconds (init: 0.135, invoke: 0.438)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3986 in cache file under /home/cecheta/.azure/telemetry/20250721170147247
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/home/linuxbrew/.linuxbrew/Cellar/azure-cli/2.75.0/libexec/bin/python /home/linuxbrew/.linuxbrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/telemetry/__init__.py /home/cecheta/.azure /home/cecheta/.azure/telemetry/20250721170147247"
telemetry.process: Return from creating process 119705
telemetry.main: Finish creating telemetry upload process.

Expected behavior

An empty blob should be uploaded to Blob storage.

Environment Summary

azure-cli 2.75.0

core 2.75.0
telemetry 1.1.0

Extensions:
application-insights 1.2.3
devcenter 7.0.0
ml 2.38.0
ssh 2.0.6

Dependencies:
msal 1.33.0b1
azure-mgmt-resource 23.3.0

Python location '/home/linuxbrew/.linuxbrew/Cellar/azure-cli/2.75.0/libexec/bin/python'
Config directory '/home/cecheta/.azure'
Extensions directory '/home/cecheta/.azure/cliextensions'

Python (Linux) 3.12.11 (main, Jun 3 2025, 15:41:47) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

Presumably, the error comes from here, where the value is checked for "falsy" rather than explicitly None.

Metadata

Metadata

Labels

Auto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamStorageaz storagequestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions