Open miniGweek opened 2 years ago
storage
We have included this as a breaking change in 2.34.1 as we think it is dangerous to overwrite files silently. --overwrite needs to be specified to overwrite files. Sorry for the inconvenience. https://docs.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest#az-storage-blob-upload
This change breaks every piece of 3rd party code using upload or upload-batch as soon as the az client is updated to 2.34.1 or higher. To workaround this, I need to manually detect the az version, then issue 2 different commands, depending on the version, since the --overwrite option does not exist in az storage upload before 2.34.1. It's not optimal imo.
--overwrite should be true by default and when not specified, to ensure backward compatibility. If a user wants to ensure that its data can't be overwritten, it could specify --overwrite false.
The azure cli should not introduce this change as GA in my humble opinon.
While it is dangerous to overwrite files silently, it is worse to break existing code without a major version release.
As a proposal which wouldn't break existing code and also would alleviate both sides of this issue, why not provide 2 flags
--overwrite
--no-overwrite
Default to having --overwrite
enabled when not specified as mentioned by @norb62 above, and print a warning on the terminal about overwriting when the flag is not set and about switching the default in a future release. In the next major version of the CLI, or after n number of minor version releases (10?) then switch the default.
This way the warning message can notify users that in the next major version of the provider (or after n number of minor releases), --no-overwrite
will become the default. If a user wants to specify no overwrites now, they can, and if they want to prepare their code for the next major version while keeping the existing functionality, then they can specify the --overwrite
flag and it will also prevent the warning from appearing.
This would be a much better way to handle the change.
A true/false option for --overwrite
would work just as well as a separate --no-overwrite
option would, by the way. Either one is fine.
We do have true/false option for --overwrite
Yes but the default is not as mentioned in my first comment.
As a proposal which wouldn't break existing code and also would alleviate both sides of this issue, why not provide 2 flags
- --overwrite
- --no-overwrite
Default to having --overwrite enabled when not specified as mentioned by @norb62 above, and print a warning on the terminal about overwriting when the flag is not set and about switching the default in a future release. In the next major version of the CLI, or after n number of minor version releases (10?) then switch the default.
To Add to above the I have noticed Running this in AzureCLIv2 Pipeline Task as ps inline script upload-batch runs fine with out using --overwrite on subsequent runs it throws an error and suggests to use --overwrite handle which takes away the error by --overwriting and not throwing error that blob already exists . Problem here is when I move into another environment with everything fixed. Script complaints about error unrecognised arguments -- overwrite
I'm looking to find out if there is a work-around for this so that we can keep -- overwrite argument for subsequent runs and to exclude it for the first run on a new environment or blob container.
Why --overwrite
is in preview?
Previously it is supported as default behavior, but now it is in preview, which means a GA feature is pulled back to preview.
Could we at least make --overwrite
not preview as first step?
This is autogenerated. Please review and update as needed.
Describe the bug
Command Name
az storage blob upload
Detailed command
az storage blob upload --account-name <my-storage-account> --container-name '$web' --file <my-file> --auth-mode login
Errors:To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
The specified blob already exists
az storage blob upload
allows the upload of the same file to the same location allowing it to be overwritten.az storage blob upload
doesn't allow the upload of the same file to the same location, instead throws an errorBlob already exists
and requires theexperimental
parameter --overwrite to be supplied.Expected Behavior
Environment Summary
Additional Context