...
DATE="$(date -ud "10 years ago" '+%Y-%m-%dT%H:%MZ')"
echo "$DATE"
...
az storage blob delete-batch \
--account-name "$NAME" \
--account-key "$KEY" \
--source "$CONTAINER" \
--if-unmodified-since "$DATE" \
--dryrun
...
I have some blobs modified in 2017, and I've tried 10 years ago (2008-04-13T16:06Z) and 10 years (2028-04-13T16:06Z) and both produce the same output:
delete action: from foo
pattern None
container foo
total 67
operations
- FILE1
- ...
...
No matter the date, I can't seem to get it to change its output 馃
pip2 install 'azure-cli==2.0.31' (also affects 2.0.28)Please try the timestamp in the format of "2018-04-13T16:00:00Z" including the second.
I had the seconds to start with, but it didn't make any difference, the docs (and other issues here) show without and so I changed it to remove the second.
Ok. @williexu, please take a look.
Ok. I see what's going on. The --dryrun parameter doesn't take the --if-unmodified-since into consideration. It was designed to help ensure the blob query string works.
Sorry for the confusion. This is indeed a bug at least indicate the documentation is misleading. Thanks for reporting this issue.
We have another issue about the same subject:
https://github.com/Azure/azure-cli/issues/5575
@troydai That isn't a dryrun then? It's effectively just listing the contents of the container which is rather pointless (isn't it?) as you already can do that with something like:
az storage blob list --container $CONTAINER --account-name $NAME --account-key $KEY --query '[].name' -o tsv
I really need to confirm before I delete that I have the correct date range to delete when writing scripts and as it currently stands the delete-batch is far less useful without being able to dryrun.
As shown in #5575, it'd need server-side support, but it seems something that should exist?
You're right, @ElvenSpellmaker. It is not supported by the service, so the client has to try our best. I will bring this to the service team. We don't want to mislead the customer. The last thing we want to happen is the CLI indicate a file will not be deleted while deleted by the service during the real operation. The logic today is conservative enough to avoid this.
The main function of the --dryrun here is to test out your listing pattern in the command. The documentation / help is not sufficient enough to point this out, and we will update that part.