azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

`storage file upload` unable to specify file name with no extension for destination

Open williexu opened this issue 8 years ago • 3 comments


The --path argument determines whether the input is a file path or directory path(in which it keeps the filename of the source) by looking at the presence of an extension in the file name here.

This makes the command unable to specify a filename with no extension to be put into the fileshare.

Environment summary

Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) / CLI version (az --version) / OS version / Shell Type (e.g. bash, cmd.exe, Bash on Windows)

williexu avatar Jan 26 '18 23:01 williexu

It has the work around. As the source file can be the file without extension, the path can just be the destination path.

I tested with the local file name without extension. It can be successfully uploaded to the destination path.

limingu avatar Apr 26 '19 23:04 limingu

This problem still persists, it seems to think that a file without an extension is a folder/directory in the fileshare.

pobby69 avatar Mar 26 '25 11:03 pobby69

Not sure why this has been closed. We're now 6 years on and I still can't upload a file with no file extension while specifying the absolute destination path.

What @pobby69 says is correct -- because there is no file extension, Azure CLI appears to interpret the last part of the path as a directory, and makes the assumption that I want to upload the file underneath that subdirectory. It shouldn't do this unless there is a trailing slash.

@limingu I'm not sure I understand what you mean by "the path can just be the destination path." Do you mean that omitting the path parameter is a workaround? Because if so, what if I need to be able to upload the file with a different filename? For example, using Powershell:

$file = New-Item -ItemType File "some_file"
az storage directory create --account-name "my_storage_account"`
--share-name "my_share_name"`
--name "some_directory"`
--account-key "my_account_key"
az storage file upload --account-name "my_storage_account"`
--share-name "my_share_name"`
--path "some_directory/some_file_with_another_name"`
--source "$($file.FullName)" `
--account-key "my_account_key"

The error:

The specified parent path does not exist.
RequestId:afd5cadc-b01a-00a5-6303-c08272000000
Time:2025-05-08T10:24:38.6574906Z
ErrorCode:ParentNotFound
Program "az.cmd" ended with non-zero exit code: 3.

The only workarounds I can see:

  • If the file already exists, then one can rename/copy the file locally so it has the same name as the destination file before uploading, purely to accommodate this bug. This isn't always possible.
  • If the file doesn't already exist, then you would need to upload the file with a file extension, copy it to a new file without a file extension, and then delete the original (since you can't rename a file on a file share.)

This should be reopened as it's a pretty basic bug, and very unclear what the issue is when it pops up.

abagonhishead avatar May 08 '25 10:05 abagonhishead