locked
How can I delete-batch blobs via --if-unmodified-since on linux? RRS feed

  • Question

  • -bash-4.2$ az storage blob list --account-name="~~~" --account-key "~~~" --container-name="pg-wal-archive" --prefix=00000001000001BA000000A --output=table
    Name                      Blob Type    Blob Tier    Length    Content Type              Last Modified              Snapshot
    ------------------------  -----------  -----------  --------  ------------------------  -------------------------  ----------
    00000001000001BA000000A0  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:23+00:00
    00000001000001BA000000A1  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:25+00:00
    00000001000001BA000000A2  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:26+00:00
    00000001000001BA000000A3  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:28+00:00
    00000001000001BA000000A4  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:30+00:00
    00000001000001BA000000A5  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:31+00:00
    00000001000001BA000000A6  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:33+00:00
    00000001000001BA000000A7  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:34+00:00
    00000001000001BA000000A8  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:36+00:00
    00000001000001BA000000A9  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:37+00:00
    00000001000001BA000000AA  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:39+00:00
    00000001000001BA000000AB  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:40+00:00
    00000001000001BA000000AC  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:42+00:00
    00000001000001BA000000AD  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:43+00:00
    00000001000001BA000000AE  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:45+00:00
    00000001000001BA000000AF  BlockBlob    Hot          16777216  application/octet-stream  2018-09-16T12:35:47+00:00
    -bash-4.2$
    -bash-4.2$ az storage blob delete-batch --source "pg-wal-archive" --account-name "~~~~" --account-key "~~~~~" --pattern 0000*  --timeout=300 --verbose --if-unmodified-since="2018-09-17T22:31Z"
    j40293 of 42093 blobs not deleted due to "Failed Precondition"
    Thursday, November 1, 2018 11:12 PM

All replies

  • Hi Robert, Could you try with the following syntax: 

            - name: Delete all blobs ending with ".py" in a container that have not been modified for 10 days.
              text: |
                date=`date -d "10 days ago" '+%Y-%m-%dT%H:%MZ'`
                az storage blob delete-batch -s MyContainer --account-name MyStorageAccount --pattern *.py --if-unmodified-since $date
    let me know if this helps

    Tuesday, November 6, 2018 10:18 PM
  • Thanks, however another post had a reply that I must create indexing before I can query on these fields . . .

    https://docs.microsoft.com/en-us/azure/search/search-howto-indexing-azure-blob-storage

    Wednesday, November 7, 2018 2:43 PM